Skip to content

Commit

Permalink
Remove test command
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtn committed Dec 29, 2020
1 parent 3af523f commit 4b00bba
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 93 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
34 changes: 0 additions & 34 deletions docs/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- [stop](#stop-command)
- [restart](#restart-command)
- [status](#status-command)
- [test](#test-command)
- [refresh](#refresh-command)
- [customize](#customize-command)

Expand Down Expand Up @@ -164,39 +163,6 @@ winsw status [<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.

## `test` command

Checks if the service can be started and then stopped without installation.

### Usage

```console
winsw test [<path-to-config>] [--no-elevate] [--timeout <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 <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.
Expand Down
58 changes: 0 additions & 58 deletions src/WinSW/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,6 @@ internal static int Main(string[] args)
root.Add(status);
}

{
var test = new Command("test", "Checks if the service can be started and then stopped without installation.")
{
Handler = CommandHandler.Create<string?, bool, bool>(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.")
{
Expand Down Expand Up @@ -809,50 +795,6 @@ static int Status(string? pathToConfig)
}
}

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);
Expand Down

0 comments on commit 4b00bba

Please sign in to comment.