Beispiel #1
0
        public CommandGroup()
        {
            if (!typeof(TCommandType).GetTypeInfo().IsEnum)
            {
                throw new NotSupportedException();
            }

            _options = new CommandGroupOptions();
        }
Beispiel #2
0
        /// <summary>
        /// Basic constructor.
        /// </summary>
        /// <param name="options">Options.</param>
        public CommandGroup(CommandGroupOptions options)
        {
            if (!typeof(TCommandType).GetTypeInfo().IsEnum)
            {
                throw new NotSupportedException();
            }

            _options = options?.DeepClone() ?? new CommandGroupOptions();
        }
Beispiel #3
0
        private void DisplayCommandHelp(Action <ColoredMultistring> outputHandler, IEnumerable <string> tokens)
        {
            if (outputHandler == null)
            {
                return;
            }

            var groupOptions = new CommandGroupOptions
            {
                ServiceConfigurer = _parserOptions.ServiceConfigurer
            };

            var group  = new CommandGroup <TCommandType>(groupOptions);
            var parser = new ArgumentSetParser(CreateArgSet(), _parserOptions.With().Quiet());

            parser.ParseTokens(tokens, group);

            var info = CommandLineParser.GetUsageInfo(
                parser.ArgumentSet,
                _parserOptions.HelpOptions,
                group);

            outputHandler(info);
        }
Beispiel #4
0
 /// <summary>
 /// Basic constructor.
 /// </summary>
 /// <param name="options">Command group options.</param>
 /// <param name="selection">The selected command type.</param>
 /// <param name="parentObject">Optionally provides a reference to the
 /// object containing this command group.</param>
 public CommandGroup(CommandGroupOptions options, object selection, object parentObject) : this(options)
 {
     _parentObject   = parentObject;
     SelectedCommand = selection;
 }