public void WithOptions(OptionParser opts) { opts.Header = "Executes a COMMAND once for each line of input on STDIN."; opts.Required.Arg<string>("COMMAND", "{0} to execute.").Do(command => settings.Command = command); opts.Args<string>("ARGUMENTS", "Additional {0} to COMMAND. Use - to grab a line from STDIN.").Do(settings.Arguments.AddRange); opts.On("verbose", 'v', "Echo each execution of COMMAND on STDERR.").Do(() => settings.Verbose = true); }
public void WithOptions(OptionParser opts) { opts.Header = "Executes a COMMAND once for each line of input on STDIN."; opts.Required.Arg <string>("COMMAND", "{0} to execute.").Do(command => settings.Command = command); opts.Args <string>("ARGUMENTS", "Additional {0} to COMMAND. Use - to grab a line from STDIN.").Do(settings.Arguments.AddRange); opts.On("verbose", 'v', "Echo each execution of COMMAND on STDERR.").Do(() => settings.Verbose = true); }
public void WithOptions(OptionParser opts) { opts.Header = "Copy standard input to each FILE, and also to standard output."; opts.Args <string>("FILE", "").Do(settings.Files.AddRange); opts.On("append", 'a', "Append to the given FILEs, do not overwrite").Do(() => settings.FileMode = FileMode.Append); opts.Footer = "With no FILE, or when a FILE is -, copy again to standard output."; }
public void WithOptions(OptionParser opts) { opts.Header = "Copy standard input to each FILE, and also to standard output."; opts.Args<string>("FILE", "").Do(settings.Files.AddRange); opts.On("append", 'a', "Append to the given FILEs, do not overwrite").Do(() => settings.FileMode = FileMode.Append); opts.Footer = "With no FILE, or when a FILE is -, copy again to standard output."; }
static int Main(string[] args) { var opts = new OptionParser(); opts.On("help", "display this help and exit").Do(() => { opts.WriteUsage(Console.Out); Environment.Exit(0); }); opts.On("version", 'V', "print version information and exit").Do(() => { opts.WriteVersionInfo(Console.Out); Environment.Exit(0); }); try { var commandType = App.Commands .SingleOrDefault(NamedAsExecutable) ?? typeof(UnknownCommand); var command = ((ICommand)Activator.CreateInstance(commandType)); command.WithOptions(opts); opts.Parse(args); return(command.Execute()); } catch (OptionParserException ex) { Console.Error.WriteLine(ex.Message); opts.WriteUsageHeader(Console.Error); Console.Error.WriteLine("\nTry `{0} --help' for more options.", App.CommandName); return(2); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return(1); } }
static int Main(string[] args) { var opts = new OptionParser(); opts.On("help", "display this help and exit").Do(() => { opts.WriteUsage(Console.Out); Environment.Exit(0); }); opts.On("version", 'V', "print version information and exit").Do(() => { opts.WriteVersionInfo(Console.Out); Environment.Exit(0); }); try { var commandType = App.Commands .SingleOrDefault(NamedAsExecutable) ?? typeof(UnknownCommand); var command = ((ICommand)Activator.CreateInstance(commandType)); command.WithOptions(opts); opts.Parse(args); return command.Execute(); } catch (OptionParserException ex) { Console.Error.WriteLine(ex.Message); opts.WriteUsageHeader(Console.Error); Console.Error.WriteLine("\nTry `{0} --help' for more options.", App.CommandName); return 2; } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return 1; } }
public void WithOptions(OptionParser opts) { opts.Header = "Show information about the file system on which each FILE resides,\nor all file systems by deafult."; opts.Args <string>("FILE", "").Do(files => { }); opts.On("block-size", 'B', "use SIZE-byte blocks").WithArg <int>("SIZE").Do(arg => { customBlockSize = true; blockSize = arg; }); opts.On("human-readable", 'h', "print sizes in human readable format (e.g., 1K 234M 2G)").Do(() => humanReadable = true); opts.On("si", 'H', "likewise, but use powers of 1000 not 1024").Do(() => humanReadableWithSi = true); opts.On("portability", 'P', "use the POSIX output format").Do(() => posixFormat = true); opts.On("type", 't', "limit listing to file systems of type TYPE").WithArg <string>("TYPE").Do(arg => limitToType = arg); opts.On("print-type", 'T', "print file system type").Do(() => printFileSystemType = true); opts.On("exclude-type", 'x', "limit listing to file systems not of type TYPE").WithArg <string>("TYPE").Do(arg => excludeType = arg); opts.Footer = "Display values are in units of the first available SIZE from --block-size,\n"; opts.Footer += "and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.\n"; opts.Footer += "Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).\n"; opts.Footer += "\n"; opts.Footer += "SIZE may be (or may be an integer optionally followed by) one of following:\n"; opts.Footer += "KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n"; }
public void WithOptions(OptionParser opts) { opts.Header = "Show information about the file system on which each FILE resides,\nor all file systems by deafult."; opts.Args<string>("FILE", "").Do(files => { }); opts.On("block-size", 'B', "use SIZE-byte blocks").WithArg<int>("SIZE").Do(arg => { customBlockSize = true; blockSize = arg; }); opts.On("human-readable", 'h', "print sizes in human readable format (e.g., 1K 234M 2G)").Do(() => humanReadable = true); opts.On("si", 'H', "likewise, but use powers of 1000 not 1024").Do(() => humanReadableWithSi = true); opts.On("portability", 'P', "use the POSIX output format").Do(() => posixFormat = true); opts.On("type", 't', "limit listing to file systems of type TYPE").WithArg<string>("TYPE").Do(arg => limitToType = arg); opts.On("print-type", 'T', "print file system type").Do(() => printFileSystemType = true); opts.On("exclude-type", 'x', "limit listing to file systems not of type TYPE").WithArg<string>("TYPE").Do(arg => excludeType = arg); opts.Footer = "Display values are in units of the first available SIZE from --block-size,\n"; opts.Footer += "and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.\n"; opts.Footer += "Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).\n"; opts.Footer += "\n"; opts.Footer += "SIZE may be (or may be an integer optionally followed by) one of following:\n"; opts.Footer += "KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n"; }
public void WithOptions(OptionParser opts) { opts.Required.Arg <Command>("COMMAND", "creates symlinks for all contained commands").Do(c => command = c); opts.On("force", 'f', "forces creation/removal of symlinks").Do(() => force = true); }