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); }
public static ICommandLineCommandInstance LoadCommand(string[] args) { if (args.Length < 1) { throw new CommandLineError("DAE-00260 Missing command parameter"); } ICommandLineCommand cmd = FindCommand(args[0]); if (cmd != null) { ICommandLineCommandInstance res = cmd.CreateInstance(); Dictionary <string, string> extparams = null; if (cmd.AllowExtParams) { extparams = new Dictionary <string, string>(); } LoadParameters(PyList.SliceFrom(args, 1), new object[] { res }, extparams); res.ExtParams = extparams; return(res); } throw new CommandLineError("DAE-00261 Command not defined:" + args[0]); }