示例#1
0
 static int Main(string[] args)
 {
     return(CommandLine.Parser.Default.ParseArguments <CircuitApp.Options, ComponentApp.Options, ComponentOutlineApp.Options>(args)
            .MapResult(
                (CircuitApp.Options options) => CircuitApp.Run(options),
                (ComponentApp.Options options) => ComponentApp.Run(options),
                (ComponentOutlineApp.Options options) => ComponentOutlineApp.Run(options),
                err => 1
                ));
 }
示例#2
0
        static void Main(string[] args)
        {
            var command = Command.Help;

            IEnumerable <string> firstLevelArgs = args;

            if (args.Length == 0)
            {
                firstLevelArgs = new[] { "-h" }
            }
            ;
            if (args.Length > 1 && (args.Last() == "-h" || args.Last() == "--help"))
            {
                firstLevelArgs = firstLevelArgs.SkipLast(1);
            }

            if (firstLevelArgs.First() == "-h" || firstLevelArgs.First() == "--help")
            {
                PrintHeader();
            }

            ArgumentSyntax.Parse(firstLevelArgs, options =>
            {
                options.ApplicationName            = "cdcli";
                options.ErrorOnUnexpectedArguments = false;

                options.DefineCommand("circuit", ref command, Command.Circuit, "Render a cddx circuit as an image.");
                options.DefineCommand("component", ref command, Command.Component, "Compile and render components.");
                options.DefineCommand("render", ref command, Command.Render, "Render a component as an image.");
            });

            switch (command)
            {
            case Command.Circuit:
            {
                CircuitApp.Run(args.Skip(1).ToArray());
                break;
            }

            case Command.Component:
            {
                ComponentApp.Run(args.Skip(1).ToArray());
                break;
            }

            case Command.Render:
            {
                RenderApp.Run(args.Skip(1).ToArray());
                break;
            }
            }
        }