Exemple #1
0
        private static void Main(string[] args)
        {
            try
            {
                var argsParser = new fmdev.ArgsParser.ArgsParser(typeof(Args));
                if (argsParser.Parse(args))
                {
                    if (argsParser.Result is Args.InfoCommand)
                    {
                        Info(argsParser.Result as Args.InfoCommand);
                    }
                    else if (argsParser.Result is Args.ConfigureCommand)
                    {
                        Configure(argsParser.Result as Args.ConfigureCommand);
                    }
                    else if (argsParser.Result is Args.ImportFileCommand)
                    {
                        ImportFile(argsParser.Result as Args.ImportFileCommand);
                    }
                    else if (argsParser.Result is Args.ExportCommand)
                    {
                        Export(argsParser.Result as Args.ExportCommand);
                    }
                    else if (argsParser.Result is Args.ExportFileCommand)
                    {
                        ExportFile(argsParser.Result as Args.ExportFileCommand);
                    }
                    else if (argsParser.Result is Args.ValidateCommand)
                    {
                        Verify(argsParser.Result as Args.ValidateCommand);
                    }
                    else if (argsParser.Result is Args.AboutCommand)
                    {
                        argsParser.PrintHeader();
                        About();
                    }
                }
                else
                {
                    System.Environment.ExitCode = 1;
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine($"Error: {e.Message}");
                if (e.InnerException != null)
                {
                    Console.Error.WriteLine($"-> {e.InnerException.Message}");
                }
#if DEBUG
                Console.Error.WriteLine($"+++ Stacktrace +++\n{e.StackTrace}");
#endif
                System.Environment.ExitCode = 1;
            }
        }
Exemple #2
0
        static int Main(string[] args)
        {
            var parser = new fmdev.ArgsParser.ArgsParser(typeof(CommandArgs));

            if (parser.Parse(args))
            {
                if (parser.Result is CommandArgs.ListCommand)
                {
                    ListUnreferenced(parser.Result as CommandArgs.ListCommand);
                }
                else if (parser.Result is CommandArgs.CleanCommand)
                {
                    CleanUnreferenced(parser.Result as CommandArgs.CleanCommand);
                }
                else
                {
                    parser.PrintUsage();
                }
            }

            return(0);
        }