示例#1
0
        public static void Main(string[] args)
        {
            BaseModule?moduleToRun = null;

            try
            {
                ConfiugreStatelessModules();
                AppSetting = AppSettingHandler.LoadAppSettings();

                string command = SubcommandParser.GetCommand(args, out string[] parameters);

                DebugHelper.WaitForDebugger(parameters);

                moduleToRun = GetModuleToRun(command);

                if (moduleToRun == null)
                {
                    Console.WriteLine(HelpUtils.GetGeneralHelp());
                    Exit(ExitCode.UnknownCommand);
                    return;
                }

                if (moduleToRun.Execute(parameters) == false)
                {
                    Console.WriteLine(moduleToRun?.GetHelp());
                    Exit(ExitCode.BadParameters);
                }
            }
            catch (Exception ex)
            {
                HandleUncaughtException(moduleToRun, ex);
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            ModuleBase?moduleToRun = null;

            try
            {
                var loaded = AppSettingHandler.LoadAppSettings();

                if (loaded != null)
                {
                    AppSetting = loaded;
                }

                var modulesWithState = CreateModules();
                ConfiugreStatelessModules(modulesWithState);


                string command = SubcommandParser.GetCommand(args, out string[] parameters);

                DebugHelper.WaitForDebugger(parameters);

                moduleToRun = GetModuleToRun(StatelessModules, modulesWithState, command);

                if (moduleToRun == null)
                {
                    Console.WriteLine(HelpUtils.GetGeneralHelp());
                    Cleanup(moduleToRun);
                    Exit(ExitCode.UnknownCommand);
                    return;
                }

                if (!moduleToRun.Execute(parameters))
                {
                    Console.WriteLine(moduleToRun.GetHelp());
                    Cleanup(moduleToRun);
                    Exit(ExitCode.BadParameters);
                }

                Cleanup(moduleToRun);
            }
            catch (Exception ex)
            {
#if TESTBUILD
                if (IsTesting)
                {
                    ErrorHappened = true;
                    ErrorText     = ex.Message;
                    return;
                }
                else
                {
#endif
                HandleUncaughtException(moduleToRun, ex);

#if TESTBUILD
            }
#endif
            }
        }
示例#3
0
        public override bool Execute(string[] arguments)
        {
            if (Modules == null)
            {
                throw new DependencyException("Modules is null");
            }

            string?helpScope = arguments.Length > 0 ? arguments[0] : string.Empty;

            var foundMoudle = Modules.FirstOrDefault(m => string.Compare(m.ModuleCommand, helpScope, true) == 0);

            if (foundMoudle == null)
            {
                Console.WriteLine(HelpUtils.GetGeneralHelp());
                Program.Exit(ExitCode.UnknownCommand);
            }
            else
            {
                Console.WriteLine(foundMoudle.GetHelp());
                Program.Exit(ExitCode.BadParameters);
            }

            return(true);
        }
示例#4
0
 public void RunHelp()
 {
     Console.WriteLine(HelpUtils.GetGeneralHelp());
 }