Exemple #1
0
        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()}");
        }
Exemple #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);
        }
Exemple #4
0
 public void Select(ICLICommand command) => SelectFunc?.Invoke(command);
Exemple #5
0
 public abstract bool IsMatch(ICLICommand command);
 internal ReturnValue_v1 FromCommand(ICLICommand cmd)
 {
     this.Command = cmd;
     return(this);
 }
Exemple #7
0
 internal CommandEvent(ICLICommand command, IUIOption opt)
 {
     Command = command;
     Option  = opt;
 }
Exemple #8
0
 public bool IsMatch(ICLICommand command)
 {
     return(MatchFunc(command));
 }
Exemple #9
0
 public bool IsMatch(ICLICommand command)
 {
     return(TriggerCommands.Any(c => String.Equals(c, command.Command, StringComparison.OrdinalIgnoreCase)));
 }
Exemple #10
0
 public override bool IsMatch(ICLICommand command)
 {
     return((UseShortcutCharacter && StrCompare(command.Command, CleanTitle[ShortcutCharacterIndex].ToString())) ||
            (UsePrefixNumber && StrCompare(command.Command, PrefixNumber.ToString())));
 }