From 02a4f738f78f68bc4e5a99c737a8a577f02962ae Mon Sep 17 00:00:00 2001 From: leaf Date: Sat, 28 Nov 2026 14:51:36 +0800 Subject: [PATCH 1/2] List saved workspaces from the command line --- README.md | 4 +++- WtProgram/CommandLine.fs | 24 ++++++++++++++++++++++-- WtProgram/Program.fs | 9 +++++++++ WtProgram/Settings.fs | 33 ++++++++++++++++++--------------- WtProgram/Shared/Strings.fs | 10 +++++----- tests/Architecture.fsx | 9 +++++++-- 6 files changed, 64 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index c11655e9..95845878 100644 --- a/README.md +++ b/README.md @@ -142,11 +142,13 @@ Run the same commands from PowerShell in the folder containing `WindowTabs.exe`: .\WindowTabs.exe --workspace "Project A" .\WindowTabs.exe --group "C:\Program Files\App\app.exe" notepad.exe .\WindowTabs.exe --commands +.\WindowTabs.exe --workspaces ``` `--group` starts the programs and puts the windows they open into one group, and `--workspace` restores a saved workspace; either also starts WindowTabs when it is not -running. `--commands` lists every command with its id. +running. `--commands` lists every command with its id, and `--workspaces` lists every saved +workspace name. ## Settings and updates diff --git a/WtProgram/CommandLine.fs b/WtProgram/CommandLine.fs index 300d238d..8cdcb067 100644 --- a/WtProgram/CommandLine.fs +++ b/WtProgram/CommandLine.fs @@ -5,6 +5,7 @@ open System.IO.Pipes open System.Runtime.InteropServices open System.Text open System.Threading +open Bemo.Json /// What a command line asks for. type CommandLineRequest = @@ -18,6 +19,7 @@ type CommandLineRequest = /// Starts the programs and puts the windows they open into one group. | StartGroup of paths:string list | ListCommands + | ListWorkspaces | Help | Invalid of string @@ -30,12 +32,13 @@ module CommandLine = | ("--workspace" | "-w")::name when not name.IsEmpty -> RestoreWorkspace(String.Join(" ",name)) | ("--group" | "-g")::paths when not paths.IsEmpty -> StartGroup paths | ["--commands"] | ["--list"] -> ListCommands + | ["--workspaces"] -> ListWorkspaces | ["--help"] | ["-h"] | ["/?"] -> Help | other -> Invalid(String.Join(" ",other)) let usage() = tr Strings.CommandLine.usage /// The options a command line may begin with, the long ones offered when one is mistyped. - let private options = ["--command";"-c";"--workspace";"-w";"--group";"-g";"--commands";"--list";"--help";"-h";"/?";"--restart"] - let private longOptions = ["--command";"--workspace";"--group";"--commands";"--help"] + let private options = ["--command";"-c";"--workspace";"-w";"--group";"-g";"--commands";"--list";"--workspaces";"--help";"-h";"/?";"--restart"] + let private longOptions = ["--command";"--workspace";"--group";"--commands";"--workspaces";"--help"] let private distance (a:string) (b:string) = let row = Array.init (b.Length+1) id for i in 1..a.Length do @@ -65,6 +68,23 @@ module CommandLine = Commands.all |> List.filter(fun command -> command.listed) |> List.map(fun command -> sprintf "%-28s %s" command.id (tr command.text.caption)) |> String.concat Environment.NewLine + /// Every saved workspace's name, one per line, from a settings JSON object. + let workspaceListing (root:JObject) = + let workspaces,_,unsupported = WorkspaceData.read root + if unsupported then "" + else + workspaces + |> List.choose(fun ws -> ws.getString("name")) + |> String.concat Environment.NewLine + /// Saved workspace names read from disk when no running copy answers the pipe. + let savedWorkspaces (isStandAlone:bool) = + try + let settingsPath,legacyPath = SettingsPaths.resolve isStandAlone + use store = new SettingsFileStore(settingsPath,250,ignore,legacyPath) + match store.Read() with + | Some text -> workspaceListing (JObject.Parse(text)) + | None -> "" + with _ -> "" /// The console the program was started from, when there is one: a window program has none of /// its own, so what the command line asks to see is written there. diff --git a/WtProgram/Program.fs b/WtProgram/Program.fs index a96e0f33..c45465ec 100644 --- a/WtProgram/Program.fs +++ b/WtProgram/Program.fs @@ -997,6 +997,7 @@ type Program(lifetime:LifetimeScope, ?settings:Settings) as this = else Result.Error (tr (Strings.CommandLine.noSuchWorkspace name)) | StartGroup paths -> this.launchGroup paths; Result.Ok "" | ListCommands -> Result.Ok (CommandLine.listing()) + | ListWorkspaces -> this.workspaceSummaries() |> List.map fst |> String.concat Environment.NewLine |> Result.Ok | Invalid given -> Result.Error (CommandLine.invalid given) | Start | Restart | Help -> Result.Ok (CommandLine.usage()) @@ -2139,6 +2140,14 @@ module Bootstrap = | ListCommands -> ConsoleOutput.write (CommandLine.listing()) 0 + | ListWorkspaces -> + match CommandPipe.send CommandPipe.name argv 3000 with + | Some(Result.Ok text) -> (if text<>"" then ConsoleOutput.write text); 0 + | Some(Result.Error text) -> ConsoleOutput.write text; 1 + | None -> + let text = CommandLine.savedWorkspaces Diagnostics.Debugger.IsAttached + if text<>"" then ConsoleOutput.write text + 0 | _ -> use instance = new SingleInstance("BemoSoftware.WindowTabs") // Starting WindowTabs again replaces the running copy, whichever build or folder either diff --git a/WtProgram/Settings.fs b/WtProgram/Settings.fs index 0dfdab06..c8c5ef41 100755 --- a/WtProgram/Settings.fs +++ b/WtProgram/Settings.fs @@ -6,7 +6,23 @@ open System.IO open System.Windows.Forms open Microsoft.FSharp.Reflection open Bemo.Json - + +module SettingsPaths = + let resolve (isStandAlone:bool) = + let fileName = "WindowTabsSettings.json" + /// The name older versions use: still read when no .json file exists yet, never written. + let legacyFileName = "WindowTabsSettings.txt" + // Resolved once, so a later working-directory change cannot redirect pending saves. + // A debug or test run (standalone) keeps its file in the working directory. Otherwise a file + // next to WindowTabs.exe makes that copy portable; this used to look in the working + // directory, which is not the exe's folder when Windows starts the app at sign-in. + let exeFolder = AppDomain.CurrentDomain.BaseDirectory + let folder = + if isStandAlone then Path.GetFullPath(".") + elif File.Exists(Path.Combine(exeFolder,fileName)) || File.Exists(Path.Combine(exeFolder,legacyFileName)) then exeFolder + else Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"WindowTabs") + Path.GetFullPath(Path.Combine(folder,fileName)),Path.GetFullPath(Path.Combine(folder,legacyFileName)) + type Settings(isStandAlone, ?saveDelay:int) as this = let mutable cachedSettingsString = None let mutable cachedSettingsRec = None @@ -17,20 +33,7 @@ type Settings(isStandAlone, ?saveDelay:int) as this = let valueCache = Dictionary() // Values already handed to other threads; cleared on every write, like valueCache. let published = Collections.Concurrent.ConcurrentDictionary() - let fileName = "WindowTabsSettings.json" - /// The name older versions use: still read when no .json file exists yet, never written. - let legacyFileName = "WindowTabsSettings.txt" - // Resolved once, so a later working-directory change cannot redirect pending saves. - // A debug or test run (standalone) keeps its file in the working directory. Otherwise a file - // next to WindowTabs.exe makes that copy portable; this used to look in the working - // directory, which is not the exe's folder when Windows starts the app at sign-in. - let exeFolder = AppDomain.CurrentDomain.BaseDirectory - let folder = - if isStandAlone then Path.GetFullPath(".") - elif File.Exists(Path.Combine(exeFolder,fileName)) || File.Exists(Path.Combine(exeFolder,legacyFileName)) then exeFolder - else Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"WindowTabs") - let settingsPath = Path.GetFullPath(Path.Combine(folder,fileName)) - let legacyPath = Path.GetFullPath(Path.Combine(folder,legacyFileName)) + let settingsPath,legacyPath = SettingsPaths.resolve isStandAlone let store = new SettingsFileStore(settingsPath,defaultArg saveDelay 250,(fun ex -> Alert.show AlertKind.Warning (tr Strings.Messages.settingsSaveFailed) (tr (Strings.Messages.unableToSaveSettings settingsPath ex.Message))), legacyPath) diff --git a/WtProgram/Shared/Strings.fs b/WtProgram/Shared/Strings.fs index 1b3ef595..225357f6 100644 --- a/WtProgram/Shared/Strings.fs +++ b/WtProgram/Shared/Strings.fs @@ -984,11 +984,11 @@ module Strings = module CommandLine = /// Shown for --help: the options, then examples to copy. - let usage = { en="Usage: WindowTabs [option]\n\nOptions:\n -c, --command [choice] Run a command in the running WindowTabs. A command that offers\n choices takes the one named, as the palette lists it.\n -w, --workspace Restore a saved workspace.\n -g, --group ... Start the programs and put the windows they open into one group.\n --commands List the commands and their ids.\n -h, --help Show this help.\n\nWith no option, WindowTabs starts, replacing a copy already running.\n\nExamples:\n WindowTabs --commands\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\nA command acts on the window in front, as its key does: run it from a shortcut or a hotkey\ntool. From a terminal, the terminal is the window in front." - zh="用法:WindowTabs [选项]\n\n选项:\n -c, --command [选项名] 在运行中的 WindowTabs 里执行命令。有选项的命令按面板中\n 列出的名称选择其中一项。\n -w, --workspace <名称> 恢复已保存的工作区。\n -g, --group <程序>... 启动这些程序,并把它们打开的窗口编成一个分组。\n --commands 列出所有命令及其 id。\n -h, --help 显示本帮助。\n\n不带选项时启动 WindowTabs,并替换正在运行的副本。\n\n示例:\n WindowTabs --commands\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\n命令作用于前台窗口,与它的快捷键相同:请从快捷方式或热键工具中运行。\n在终端中运行时,前台窗口就是终端本身。" - ja="使い方: WindowTabs [オプション]\n\nオプション:\n -c, --command [選択肢] 実行中の WindowTabs でコマンドを実行します。選択肢のある\n コマンドは、パレットに表示される名前で選びます。\n -w, --workspace <名前> 保存済みのワークスペースを復元します。\n -g, --group <プログラム>... プログラムを起動し、開いたウィンドウを 1 つのグループにまとめます。\n --commands コマンドとその id を一覧表示します。\n -h, --help このヘルプを表示します。\n\nオプションなしでは WindowTabs を起動し、実行中のコピーを置き換えます。\n\n例:\n WindowTabs --commands\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\nコマンドはキーと同じく前面のウィンドウに働きます。ショートカットやホットキー\nツールから実行してください。ターミナルから実行すると、前面にあるのはターミナルです。" - ar="الاستخدام: WindowTabs [خيار]\n\nالخيارات:\n -c, --command [اختيار] يشغّل أمرًا في WindowTabs العامل. الأمر الذي يعرض خيارات\n يأخذ المسمّى منها كما تسرده اللوحة.\n -w, --workspace <اسم> يستعيد مساحة عمل محفوظة.\n -g, --group <برنامج>... يشغّل البرامج ويضع النوافذ التي تفتحها في مجموعة واحدة.\n --commands يعرض الأوامر ومعرّفاتها.\n -h, --help يعرض هذه المساعدة.\n\nبدون خيار، يبدأ WindowTabs ويحل محل النسخة العاملة.\n\nأمثلة:\n WindowTabs --commands\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\nيعمل الأمر على النافذة الأمامية كما يفعل مفتاحه: شغّله من اختصار أو من أداة مفاتيح\nتشغيل سريع. من الطرفية، الطرفية نفسها هي النافذة الأمامية." - ko="사용법: WindowTabs [옵션]\n\n옵션:\n -c, --command [선택] 실행 중인 WindowTabs에서 명령을 실행합니다. 선택 항목이 있는\n 명령은 팔레트에 표시되는 이름으로 하나를 고릅니다.\n -w, --workspace <이름> 저장된 작업 공간을 복원합니다.\n -g, --group <프로그램>... 프로그램을 시작하고, 열린 창을 하나의 그룹으로 묶습니다.\n --commands 명령과 해당 id를 나열합니다.\n -h, --help 이 도움말을 표시합니다.\n\n옵션 없이 실행하면 WindowTabs를 시작하고, 이미 실행 중인 복사본을 대체합니다.\n\n예:\n WindowTabs --commands\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\n명령은 해당 키와 마찬가지로 현재 창에 적용됩니다. 바로 가기나 단축키\n도구에서 실행하세요. 터미널에서 실행하면 현재 창은 터미널입니다." } + let usage = { en="Usage: WindowTabs [option]\n\nOptions:\n -c, --command [choice] Run a command in the running WindowTabs. A command that offers\n choices takes the one named, as the palette lists it.\n -w, --workspace Restore a saved workspace.\n -g, --group ... Start the programs and put the windows they open into one group.\n --commands List the commands and their ids.\n --workspaces List the saved workspace names.\n -h, --help Show this help.\n\nWith no option, WindowTabs starts, replacing a copy already running.\n\nExamples:\n WindowTabs --commands\n WindowTabs --workspaces\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\nA command acts on the window in front, as its key does: run it from a shortcut or a hotkey\ntool. From a terminal, the terminal is the window in front." + zh="用法:WindowTabs [选项]\n\n选项:\n -c, --command [选项名] 在运行中的 WindowTabs 里执行命令。有选项的命令按面板中\n 列出的名称选择其中一项。\n -w, --workspace <名称> 恢复已保存的工作区。\n -g, --group <程序>... 启动这些程序,并把它们打开的窗口编成一个分组。\n --commands 列出所有命令及其 id。\n --workspaces 列出所有已保存的工作区名称。\n -h, --help 显示本帮助。\n\n不带选项时启动 WindowTabs,并替换正在运行的副本。\n\n示例:\n WindowTabs --commands\n WindowTabs --workspaces\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\n命令作用于前台窗口,与它的快捷键相同:请从快捷方式或热键工具中运行。\n在终端中运行时,前台窗口就是终端本身。" + ja="使い方: WindowTabs [オプション]\n\nオプション:\n -c, --command [選択肢] 実行中の WindowTabs でコマンドを実行します。選択肢のある\n コマンドは、パレットに表示される名前で選びます。\n -w, --workspace <名前> 保存済みのワークスペースを復元します。\n -g, --group <プログラム>... プログラムを起動し、開いたウィンドウを 1 つのグループにまとめます。\n --commands コマンドとその id を一覧表示します。\n --workspaces 保存済みのワークスペース名を一覧表示します。\n -h, --help このヘルプを表示します。\n\nオプションなしでは WindowTabs を起動し、実行中のコピーを置き換えます。\n\n例:\n WindowTabs --commands\n WindowTabs --workspaces\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\nコマンドはキーと同じく前面のウィンドウに働きます。ショートカットやホットキー\nツールから実行してください。ターミナルから実行すると、前面にあるのはターミナルです。" + ar="الاستخدام: WindowTabs [خيار]\n\nالخيارات:\n -c, --command [اختيار] يشغّل أمرًا في WindowTabs العامل. الأمر الذي يعرض خيارات\n يأخذ المسمّى منها كما تسرده اللوحة.\n -w, --workspace <اسم> يستعيد مساحة عمل محفوظة.\n -g, --group <برنامج>... يشغّل البرامج ويضع النوافذ التي تفتحها في مجموعة واحدة.\n --commands يعرض الأوامر ومعرّفاتها.\n --workspaces يعرض أسماء مساحات العمل المحفوظة.\n -h, --help يعرض هذه المساعدة.\n\nبدون خيار، يبدأ WindowTabs ويحل محل النسخة العاملة.\n\nأمثلة:\n WindowTabs --commands\n WindowTabs --workspaces\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\nيعمل الأمر على النافذة الأمامية كما يفعل مفتاحه: شغّله من اختصار أو من أداة مفاتيح\nتشغيل سريع. من الطرفية، الطرفية نفسها هي النافذة الأمامية." + ko="사용법: WindowTabs [옵션]\n\n옵션:\n -c, --command [선택] 실행 중인 WindowTabs에서 명령을 실행합니다. 선택 항목이 있는\n 명령은 팔레트에 표시되는 이름으로 하나를 고릅니다.\n -w, --workspace <이름> 저장된 작업 공간을 복원합니다.\n -g, --group <프로그램>... 프로그램을 시작하고, 열린 창을 하나의 그룹으로 묶습니다.\n --commands 명령과 해당 id를 나열합니다.\n --workspaces 저장된 작업 공간 이름을 나열합니다.\n -h, --help 이 도움말을 표시합니다.\n\n옵션 없이 실행하면 WindowTabs를 시작하고, 이미 실행 중인 복사본을 대체합니다.\n\n예:\n WindowTabs --commands\n WindowTabs --workspaces\n WindowTabs --command next-tab\n WindowTabs --command tab-color Blue\n WindowTabs --command group-tab-position Left\n WindowTabs --command restore-workspace-named \"Project A\"\n WindowTabs --workspace \"Project A\"\n WindowTabs --group notepad.exe \"C:\\Program Files\\App\\app.exe\"\n\n명령은 해당 키와 마찬가지로 현재 창에 적용됩니다. 바로 가기나 단축키\n도구에서 실행하세요. 터미널에서 실행하면 현재 창은 터미널입니다." } let unknownCommand id = { en=sprintf "No command is called %s. --commands lists them." id; zh=sprintf "没有名为 %s 的命令。--commands 可列出全部命令。" id; ja=sprintf "%s というコマンドはありません。--commands で一覧表示できます。" id; ar=sprintf "لا يوجد أمر باسم %s. يعرض --commands الأوامر." id; ko=sprintf "%s(이)라는 명령이 없습니다. --commands로 목록을 볼 수 있습니다." id } let unavailable caption = { en=sprintf "%s has nothing to act on for the window in front." caption; zh=sprintf "“%s”对当前前台窗口无可操作的内容。" caption; ja=sprintf "「%s」は前面のウィンドウに対して実行できる操作がありません。" caption; ar=sprintf "لا يجد «%s» ما يعمل عليه في النافذة الأمامية." caption; ko=sprintf "현재 창에서는 ‘%s’을(를) 실행할 수 없습니다." caption } /// A command line that is not one: what was wrong, and where to look. diff --git a/tests/Architecture.fsx b/tests/Architecture.fsx index 7a22db0f..2c50da8c 100644 --- a/tests/Architecture.fsx +++ b/tests/Architecture.fsx @@ -1474,15 +1474,20 @@ let main() = | Invalid _ | Start | Help -> failwithf "The help's example %s is not read as a request" example | RunCommand(id,_) -> check (Commands.find id).IsSome (sprintf "The help's example names no command %s" id) | _ -> () - for option in ["--command";"-c";"--workspace";"-w";"--group";"-g";"--commands";"--help";"-h"] do + for option in ["--command";"-c";"--workspace";"-w";"--group";"-g";"--commands";"--workspaces";"--help";"-h"] do check (help.Contains option) (sprintf "The %s help leaves out %s" language option) check (CommandLine.parse [|"--command";"next-tab"|]=RunCommand("next-tab",None)) "A command by id was not read" check (CommandLine.parse [|"-c";"tab-color";"Sky";"blue"|]=RunCommand("tab-color",Some "Sky blue")) "A command's choice was not read whole" check (CommandLine.parse [|"--workspace";"Dev";"work"|]=RestoreWorkspace "Dev work") "A workspace name with a space was not read whole" check (CommandLine.parse [|"--group";"a.exe";"b.exe"|]=StartGroup ["a.exe";"b.exe"]) "The programs of a group were not read" - check (CommandLine.parse [|"--commands"|]=ListCommands && CommandLine.parse [|"--help"|]=Help) "The listing and help were not read" + check (CommandLine.parse [|"--commands"|]=ListCommands && CommandLine.parse [|"--workspaces"|]=ListWorkspaces && CommandLine.parse [|"--help"|]=Help) "The listings and help were not read" + check ((CommandLine.invalid "--workspces").Contains (tr (Strings.CommandLine.didYouMean "--workspaces"))) "A mistyped --workspaces did not suggest it" check ((match CommandLine.parse [|"--bogus"|] with Invalid _ -> true | _ -> false) && (match CommandLine.parse [|"--group"|] with Invalid _ -> true | _ -> false)) "An unknown or incomplete command line was accepted" check (CommandLine.listing().Contains "command-palette") "The listing left out the palette" + check (CommandLine.workspaceListing (Bemo.Json.JObject())="") "An empty settings object listed workspaces" + let sampleWorkspaces = + Bemo.Json.JObject.Parse("""{"workspaceSchemaVersion":1,"workspaces":[{"name":"Project A","groups":[]},{"name":"Daily","groups":[]}]}""") + check (CommandLine.workspaceListing sampleWorkspaces="Project A"+Environment.NewLine+"Daily") "Saved workspace names were not listed one per line" let pipe = "BemoSoftware.WindowTabs.Test."+Guid.NewGuid().ToString("N") do use server = new CommandServer(pipe,fun argv -> if argv.Length=0 then Result.Error "nothing" else Result.Ok(String.Join("+",argv))) From 48a8099ef1c476ede62d1cbbcd195474e24fd60d Mon Sep 17 00:00:00 2001 From: leaf Date: Sat, 28 Nov 2026 19:06:51 +0800 Subject: [PATCH 2/2] Test multilingual workspace listing and pipe round trips --- tests/Architecture.fsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Architecture.fsx b/tests/Architecture.fsx index 2c50da8c..ecbf7150 100644 --- a/tests/Architecture.fsx +++ b/tests/Architecture.fsx @@ -1488,10 +1488,17 @@ let main() = let sampleWorkspaces = Bemo.Json.JObject.Parse("""{"workspaceSchemaVersion":1,"workspaces":[{"name":"Project A","groups":[]},{"name":"Daily","groups":[]}]}""") check (CommandLine.workspaceListing sampleWorkspaces="Project A"+Environment.NewLine+"Daily") "Saved workspace names were not listed one per line" + let multilingualNames = ["项目 A";"仕事用";"업무 공간";"Проект";"مشروع";"Café";"Cafe\u0301";"Workspace 🚀";"Research & Design"] + let multilingualSettings = Bemo.Json.JObject.Parse("""{"workspaceSchemaVersion":1,"workspaces":[{"name":"项目 A","groups":[]},{"name":"仕事用","groups":[]},{"name":"업무 공간","groups":[]},{"name":"Проект","groups":[]},{"name":"مشروع","groups":[]},{"name":"Café","groups":[]},{"name":"Cafe\u0301","groups":[]},{"name":"Workspace 🚀","groups":[]},{"name":"Research & Design","groups":[]}]}""") + check (CommandLine.workspaceListing multilingualSettings=String.concat Environment.NewLine multilingualNames) "Multilingual workspace listing changed names" + for name in multilingualNames do + check (CommandLine.parse [|"--workspace";name|]=RestoreWorkspace name) "Multilingual workspace argument changed" let pipe = "BemoSoftware.WindowTabs.Test."+Guid.NewGuid().ToString("N") do use server = new CommandServer(pipe,fun argv -> if argv.Length=0 then Result.Error "nothing" else Result.Ok(String.Join("+",argv))) check (CommandPipe.send pipe [|"--command";"next-tab"|] 3000=Some(Result.Ok "--command+next-tab")) "The pipe did not carry a command line and its reply" + for name in multilingualNames do + check (CommandPipe.send pipe [|"--workspace";name|] 3000=Some(Result.Ok ("--workspace+"+name))) "The pipe changed a multilingual workspace name" check (CommandPipe.send pipe [||] 3000=Some(Result.Error "nothing")) "The pipe did not carry a refusal" check (CommandPipe.send pipe [|"again"|] 3000=Some(Result.Ok "again")) "The pipe did not take a second command line" check (CommandPipe.send (pipe+".gone") [|"x"|] 200).IsNone "Sending to no listener did not say so"