Beispiel #1
0
        void ExecuteCommandType(Type cmdT, string[] args)
        {
            ICLICommand o = (ICLICommand)Activator.CreateInstance(cmdT);

            o.OnQuit += (object sender, EventArgs e) => QuitCommand();
            o.Execute(args);
        }
Beispiel #2
0
        /// <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()}");
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public void Select(ICLICommand command) => SelectFunc?.Invoke(command);
Beispiel #5
0
 public abstract bool IsMatch(ICLICommand command);
Beispiel #6
0
 internal ReturnValue_v1 FromCommand(ICLICommand cmd)
 {
     this.Command = cmd;
     return(this);
 }
Beispiel #7
0
 internal CommandEvent(ICLICommand command, IUIOption opt)
 {
     Command = command;
     Option  = opt;
 }
Beispiel #8
0
 public bool IsMatch(ICLICommand command)
 {
     return(MatchFunc(command));
 }
Beispiel #9
0
 public bool IsMatch(ICLICommand command)
 {
     return(TriggerCommands.Any(c => String.Equals(c, command.Command, StringComparison.OrdinalIgnoreCase)));
 }
Beispiel #10
0
 public override bool IsMatch(ICLICommand command)
 {
     return((UseShortcutCharacter && StrCompare(command.Command, CleanTitle[ShortcutCharacterIndex].ToString())) ||
            (UsePrefixNumber && StrCompare(command.Command, PrefixNumber.ToString())));
 }