Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var config = new CommandLineParser.Arguments.FileArgument('c', "config")
            {
                ForcedDefaultValue = new FileInfo("config.json")
            };

            var commandLineParser = new CommandLineParser.CommandLineParser()
            {
                Arguments =
                {
                    config,
                }
            };

            try
            {
                commandLineParser.ParseCommandLine(args);

                AsyncMain(new ConfigurationBuilder()
                          .AddJsonFile(config.Value.FullName, true)
                          .Build()).Wait();
            }
            catch (CommandLineParser.Exceptions.CommandLineException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        static void ParseCommandLine(string[] args, out CommandLineParser.Arguments.FileArgument config, out CommandLineParser.Arguments.SwitchArgument debug, out CommandLineParser.Arguments.SwitchArgument fetch, out CommandLineParser.Arguments.SwitchArgument summary)
        {
            config = new CommandLineParser.Arguments.FileArgument('c', "config")
            {
                ForcedDefaultValue = new FileInfo("config.json")
            };

            debug = new CommandLineParser.Arguments.SwitchArgument('d', "debug", false);

            fetch = new CommandLineParser.Arguments.SwitchArgument('f', "fetch", false);

            summary = new CommandLineParser.Arguments.SwitchArgument('s', "summary", false);

            var commandLineParser = new CommandLineParser.CommandLineParser()
            {
                Arguments =
                {
                    config,
                    debug,
                    fetch,
                    summary,
                }
            };

            commandLineParser.ParseCommandLine(args);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var config = new CLP.Arguments.FileArgument('c', "config")
            {
                ForcedDefaultValue = new FileInfo("config.json"),
            };
            var verbose = new CLP.Arguments.SwitchArgument('v', "verbose", false);
            var offset  = new CLP.Arguments.ValueArgument <int>('o', "offset")
            {
                ForcedDefaultValue = 0,
            };
            var range = new CLP.Arguments.ValueArgument <int>('r', "range")
            {
                ForcedDefaultValue = 1,
            };

            var commandLineParser = new CLP.CommandLineParser()
            {
                Arguments =
                {
                    config,
                    verbose,
                    offset,
                    range,
                }
            };

            try
            {
                commandLineParser.ParseCommandLine(args);

                Main(new ConfigurationBuilder()
                     .AddJsonFile(config.Value.FullName, true)
                     .Build(), LoadConfig(config.Value.FullName), verbose.Value, offset.Value, range.Value)
                .Wait();
            }
            catch (CLP.Exceptions.CommandLineException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 4
0
 static IConfigurationRoot LoadConfiguration(CommandLineParser.Arguments.FileArgument config)
 {
     return(new ConfigurationBuilder()
            .AddJsonFile(config.Value.FullName, true)
            .Build());
 }