Remove `/redirect` option

pull/557/head
NextTurn 2020-02-17 00:00:00 +08:00 committed by Next Turn
parent 3b2a9354c0
commit eac8b8ca45
3 changed files with 1 additions and 31 deletions

View File

@ -88,20 +88,7 @@ namespace winsw
return; return;
} }
var args = new List<string>(Array.AsReadOnly(argsArray)); var args = new List<string>(argsArray);
if (args[0] == "/redirect")
{
var f = new FileStream(args[1], FileMode.Create);
var w = new StreamWriter(f) { AutoFlush = true };
Console.SetOut(w);
Console.SetError(w);
var handle = f.SafeFileHandle;
_ = Kernel32.SetStdHandle(-11, handle); // set stdout
_ = Kernel32.SetStdHandle(-12, handle); // set stder
args = args.GetRange(2, args.Count - 2);
}
bool elevated; bool elevated;
if (args[0] == "/elevated") if (args[0] == "/elevated")
@ -692,9 +679,6 @@ namespace winsw
Console.WriteLine(); Console.WriteLine();
PrintAvailableCommands(); PrintAvailableCommands();
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Extra options:");
Console.WriteLine(" /redirect redirect the wrapper's STDOUT and STDERR to the specified file");
Console.WriteLine();
PrintVersion(); PrintVersion();
Console.WriteLine("More info: https://github.com/winsw/winsw"); Console.WriteLine("More info: https://github.com/winsw/winsw");
Console.WriteLine("Bug tracker: https://github.com/winsw/winsw/issues"); Console.WriteLine("Bug tracker: https://github.com/winsw/winsw/issues");

View File

@ -1,11 +0,0 @@
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
namespace winsw.Native
{
internal static class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern bool SetStdHandle(int stdHandle, SafeFileHandle handle);
}
}

View File

@ -51,9 +51,6 @@ namespace winswTests
Assert.That(cliOut, Does.Contain("help")); Assert.That(cliOut, Does.Contain("help"));
Assert.That(cliOut, Does.Contain("version")); Assert.That(cliOut, Does.Contain("version"));
// TODO: check all commands after the migration of ccommands to enum // TODO: check all commands after the migration of ccommands to enum
// Extra options
Assert.That(cliOut, Does.Contain("/redirect"));
} }
[Test] [Test]