示例#1
0
        static public int Main(string[] args)
        {
            var t = Parser.Default.ParseArguments <CheckOptions, ErrorCodeOptions>(args)
                    .MapResult(
                (CheckOptions opts) => CheckOptions.Run(opts, Console.Out),
                (ErrorCodeOptions opts) => ErrorCodeOptions.Run(opts),
                errs => Status.CommandLineError);

            return((int)t);
        }
示例#2
0
        internal static Status Run(ErrorCodeOptions opts)
        {
            try
            {
                Status s        = (Status)opts.RequestedCode;
                var    asString = s.ToString();
                if (asString == opts.RequestedCode.ToString())
                {
                    Console.WriteLine($"The requested error code {opts.RequestedCode} appears meaningless.");
                }
                else
                {
                    Console.WriteLine(asString);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error parsing the requested error code {opts.RequestedCode}, {ex.Message}.");
            }

            return(Status.Ok);
        }