diff --git a/README.md b/README.md index 4725936..9d52478 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,6 @@ Your renamed *WinSW.exe* binary also accepts the following commands: | [stop](docs/cli-commands.md#stop-command) | Stops the service. | | [restart](docs/cli-commands.md#restart-command) | Stops and then starts the service. | | [status](docs/cli-commands.md#status-command) | Checks the status of the service. | -| [test](docs/cli-commands.md#test-command) | Checks if the service can be started and then stopped without installation. | | [refresh](docs/cli-commands.md#refresh-command) | Refreshes the service properties without reinstallation. | | [customize](docs/cli-commands.md#customize-command) | Customizes the wrapper executable. | | dev | Experimental commands. | diff --git a/docs/cli-commands.md b/docs/cli-commands.md index 0405fa4..50221dc 100644 --- a/docs/cli-commands.md +++ b/docs/cli-commands.md @@ -8,7 +8,6 @@ - [stop](#stop-command) - [restart](#restart-command) - [status](#status-command) -- [test](#test-command) - [refresh](#refresh-command) - [customize](#customize-command) @@ -164,39 +163,6 @@ winsw status [] The path to the configuration file. If a file isn't specified, WinSW searches the executable directory for a *.xml* file with the same file name without the extension. -## `test` command - -Checks if the service can be started and then stopped without installation. - -### Usage - -```console -winsw test [] [--no-elevate] [--timeout ] [--no-break] -``` - -### Arguments - -`path-to-config` - -The path to the configuration file. -If a file isn't specified, WinSW searches the executable directory for a *.xml* file with the same file name without the extension. - -### Options - -- `--no-elevate` - - Doesn't automatically trigger a UAC prompt. - -- `--timeout ` - - Specifies the number of seconds to wait before the service is stopped. - If not specified or -1 is specified, WinSW waits for a keystroke indefinitely. - -- `--no-break` - - Ignores keystrokes. - If specified, WinSW waits for Ctrl+C. - ## `refresh` command Refreshes the service properties without reinstallation. diff --git a/src/WinSW/Program.cs b/src/WinSW/Program.cs index fd4532f..6ddaf0a 100644 --- a/src/WinSW/Program.cs +++ b/src/WinSW/Program.cs @@ -248,20 +248,6 @@ namespace WinSW root.Add(status); } - { - var test = new Command("test", "Checks if the service can be started and then stopped without installation.") - { - Handler = CommandHandler.Create(Test), - }; - - test.Add(config); - test.Add(noElevate); - - test.Add(new Option("--no-break", "Ignores keystrokes.")); - - root.Add(test); - } - { var refresh = new Command("refresh", "Refreshes the service properties without reinstallation.") { @@ -809,50 +795,6 @@ namespace WinSW } } - void Test(string? pathToConfig, bool noElevate, bool noBreak) - { - var config = LoadConfigAndInitLoggers(pathToConfig, true); - - if (!elevated) - { - Elevate(noElevate); - return; - } - - AutoRefresh(config); - - using var wsvc = new WrapperService(config); - wsvc.RaiseOnStart(args); - try - { - if (!noBreak) - { - Console.WriteLine("Press any key to stop the service..."); - _ = Console.ReadKey(); - } - else - { - using var evt = new ManualResetEvent(false); - - Console.WriteLine("Press Ctrl+C to stop the service..."); - Console.CancelKeyPress += CancelKeyPress; - - _ = evt.WaitOne(); - Console.CancelKeyPress -= CancelKeyPress; - - void CancelKeyPress(object? sender, ConsoleCancelEventArgs e) - { - e.Cancel = true; - evt.Set(); - } - } - } - finally - { - wsvc.RaiseOnStop(); - } - } - void Refresh(string? pathToConfig, bool noElevate) { var config = LoadConfigAndInitLoggers(pathToConfig, true);