示例#1
0
    public void Run(string[] args)
    {
        ProjectCommandLineApplication userJwts = new(_reporter)
        {
            Name = "dotnet user-jwts"
        };

        userJwts.HelpOption("-h|--help");

        // dotnet user-jwts list
        ListCommand.Register(userJwts);
        // dotnet user-jwts create
        CreateCommand.Register(userJwts);
        // dotnet user-jwts print ecd045
        PrintCommand.Register(userJwts);
        // dotnet user-jwts remove ecd045
        RemoveCommand.Register(userJwts);
        // dotnet user-jwts clear
        ClearCommand.Register(userJwts);
        // dotnet user-jwts key
        KeyCommand.Register(userJwts);

        // Show help information if no subcommand/option was specified.
        userJwts.OnExecute(() => userJwts.ShowHelp());

        try
        {
            userJwts.Execute(args);
        }
        catch (Exception ex)
        {
            _reporter.Error(ex.Message);
        }
    }
}
示例#2
0
        static int Main(string[] args)
        {
            if (args.Any(a => a == "--debug"))
            {
                args = args.Where(a => a != "--debug").ToArray();
                Console.WriteLine($"Waiting for debugger to attach. Process ID: {System.Diagnostics.Process.GetCurrentProcess().Id}");
                Console.WriteLine("Press ENTER to continue.");
                Console.ReadLine();
            }

            var app = new CommandLineApplication();

            app.Name     = Name;
            app.FullName = "ILspect Command-Line Interface";
            app.HelpOption("-h|-?|--help");
            app.VersionOption("-v|--version", Program.Version);

            ListCommand.Register(app);
            GraphCommand.Register(app);
            DisassembleCommand.Register(app);
            SyntaxCommand.Register(app);

            CommandHelpers.RegisterHelpCommand(app);

            app.OnExecute(() =>
            {
                app.ShowHelp();
                return(0);
            });

            try
            {
                return(app.Execute(args));
            }
            catch (Exception ex)
            {
                CommandHelpers.Error(ex.Message);

#if DEBUG
                CommandHelpers.Error(ex.ToString());
#endif

                return(-1);
            }
        }