public override void RunCommand() { ICommandLineCommand cmd = CmdLine.FindCommand(Command); if (cmd == null) { throw new CommandLineError("DAE-00154 Unknown command:" + Command); } ICommandLineCommandInstance inst = cmd.CreateInstance(); List <CmdLine.ParamHolder> holders = CmdLine.LoadHolders(new object[] { inst }); Dictionary <int, string> posparams = new Dictionary <int, string>(); foreach (CmdLine.ParamHolder holder in holders) { if (holder.Position != null) { posparams[holder.Position.Value] = holder.Name; } } List <string> posparamslist = new List <string>(); while (posparams.Count > 0) { int min = PyList.Minimum(posparams.Keys); posparamslist.Add(posparams[min]); posparams.Remove(min); } Console.Out.WriteLine("Usage: daci " + Command + " " + String.Join(" ", posparamslist.ToArray()) + " [--param1 value1 --param2 value2...]"); Console.Out.WriteLine(cmd.Description); foreach (CmdLine.ParamHolder holder in holders) { Console.WriteLine(" " + holder.Name + " - " + holder.Description); } }
static void Main(string[] args) { Core.IsCommandLine = true; Core.Instance.CreateWantedDirs(); Core.ConfigureLogging(); FileTextProvider.LoadStdTexts(); LicenseTool.ReloadLicenses(); PluginTools.AddMasterAssembly(Assembly.GetAssembly(typeof(DaciProgram))); PluginTools.LoadPlugins(); GlobalSettings.Initialize(); InternetSettings.Initialize(); HSettings.CallLoaded(); //Async.MainThread = Thread.CurrentThread; try { if (args.Length == 0) { CmdLine.PrintHelp(); Environment.Exit(0); } Logging.Info("Starting DACI - DatAdmin CommandLine interface"); ICommandLineCommandInstance cmd = CmdLine.LoadCommand(args); cmd.RunCommand(); } catch (ExpectedError e) { Logging.Error(e.Message); } catch (Exception e) { Logging.Error("Fatal error:" + e.ToString()); } Logging.QuitAndWait(); Core.FinalizeApp(); Environment.Exit(0); }