static int Main(string[] args)
        {
            // Create a shell command based on the arguments. The CreateShellCommand method will catch any command line errors
            // and print error details and usage information on the console, so we don't have to worry about that here.
            CreateShellCommandOptions options = new CreateShellCommandOptions();

            options.UsageOptions.IncludeDefaultValueInDescription = true;
            options.UsageOptions.IncludeAliasInDescription        = true;
            ShellCommand command = ShellCommand.CreateShellCommand(Assembly.GetExecutingAssembly(), args, 0, options);

            if (command != null)
            {
                // The command line arguments were successfully parsed, so run the command.
                command.Run();
                // When using shell commands, it's good practice to return the value of the ExitStatus property to the operating system.
                // The application or script that invoked your application can check the exit code from your application to
                // see if you were successful or not. Error codes are completely application specific, but usually 0 is used to
                // indicate success, and any other value indicates an error.
                return(command.ExitCode);
            }

            return(1); // Return an error status if the command couldn't be created.
        }
Exemple #2
0
 public CustomParsingCommand(string[] args, int index, CreateShellCommandOptions options)
 {
     Value = args[index];
 }