Пример #1
0
 private static void ProcessData(H3ToComponentsParser data)
 {
     if (data.Verbose)
     {
         FancyDump(data.H3);
     }
     else
     {
         SimpleDump(data.H3);
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            using var parser = new CommandLineParser.CommandLineParser();

            args = args.Select(s => s.ToLower()).ToArray();

            SwitchArgument verbose = new SwitchArgument('v', "verbose", "Show verbose debugging info", false);

            verbose.Optional = true;

            ValueArgument <H3Index> h3 = new ValueArgument <H3Index>
                                             ('h', "h3index", "H3Index (in hexadecimal) to examine");

            h3.ConvertValueHandler = value => value.ToH3Index();

            parser.Arguments.Add(verbose);
            parser.Arguments.Add(h3);

            try
            {
                var argParser = new H3ToComponentsParser();
                parser.ExtractArgumentAttributes(argParser);
                parser.ParseCommandLine(args);

                if (h3.Parsed)
                {
                    var data = new H3ToComponentsParser {
                        Verbose = verbose.Value, H3 = h3.Value
                    };
                    ProcessData(data);
                }
                else
                {
                    Console.WriteLine("Unable to parse input.");
                    parser.ShowUsage();
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Unable to parse input.");
                parser.ShowUsage();
            }
        }