void ExecuteCommandType(Type cmdT, string[] args) { ICLICommand o = (ICLICommand)Activator.CreateInstance(cmdT); o.OnQuit += (object sender, EventArgs e) => QuitCommand(); o.Execute(args); }
/// <summary> /// Adds the command to the list of the commands /// </summary> /// <param name="cmd">The command.</param> /// <returns></returns> /// <exception cref="ArgumentException">unsupported type {cmd?.GetType()}</exception> public CLI_Commands AddCommand(ICLICommand cmd) { if (cmd is CLICommand_v1 v) { Commands_v1.Add(v); return(this); } throw new ArgumentException($"unsupported type {cmd?.GetType()}"); }
internal IUIOption FindOption(ICLICommand command) { if (OptionCollection == null) { throw new InvalidOperationException($"{nameof(OptionCollection)} cannot be null while processing options."); } //tolist prevents potential errors from editing the list foreach (var option in OptionCollection.ActiveOptions.ToList()) { if (option.IsMatch(command)) { return(option); } } return(null); }
public void Select(ICLICommand command) => SelectFunc?.Invoke(command);
public abstract bool IsMatch(ICLICommand command);
internal ReturnValue_v1 FromCommand(ICLICommand cmd) { this.Command = cmd; return(this); }
internal CommandEvent(ICLICommand command, IUIOption opt) { Command = command; Option = opt; }
public bool IsMatch(ICLICommand command) { return(MatchFunc(command)); }
public bool IsMatch(ICLICommand command) { return(TriggerCommands.Any(c => String.Equals(c, command.Command, StringComparison.OrdinalIgnoreCase))); }
public override bool IsMatch(ICLICommand command) { return((UseShortcutCharacter && StrCompare(command.Command, CleanTitle[ShortcutCharacterIndex].ToString())) || (UsePrefixNumber && StrCompare(command.Command, PrefixNumber.ToString()))); }