CommandNameFor() 공개 정적인 메소드

public static CommandNameFor ( Type type ) : string
type System.Type
리턴 string
예제 #1
0
        public UsageGraph(Type commandType)
        {
            _commandType = commandType;
            _inputType   = commandType.FindInterfaceThatCloses(typeof(IFubuCommand <>)).GetGenericArguments().First();

            _commandName = CommandFactory.CommandNameFor(commandType);
            _commandType.ForAttribute <CommandDescriptionAttribute>(att => { _description = att.Description; });

            if (_description == null)
            {
                _description = _commandType.Name;
            }

            _handlers = InputParser.GetHandlers(_inputType);

            _commandType.ForAttribute <UsageAttribute>(att =>
            {
                _usages.Add(buildUsage(att));
            });

            if (!_usages.Any())
            {
                var usage = new CommandUsage()
                {
                    CommandName = _commandName,
                    UsageKey    = "default",
                    Description = _description,
                    Arguments   = _handlers.OfType <Argument>(),
                    ValidFlags  = _handlers.Where(x => !(x is Argument))
                };

                _usages.Add(usage);
            }
        }
예제 #2
0
        public UsageGraph(Type commandType)
        {
            _commandType = commandType;
            _inputType   = commandType.FindInterfaceThatCloses(typeof(IFubuCommand <>)).GetGenericArguments().First();

            _commandName = CommandFactory.CommandNameFor(commandType);
            _commandType.ForAttribute <CommandDescriptionAttribute>(att => { _description = att.Description; });

            if (_description == null)
            {
                _description = _commandType.Name;
            }

            _handlers = InputParser.GetHandlers(_inputType);

            _validUsages = new Lazy <IEnumerable <CommandUsage> >(() => {
                if (_usages.Any())
                {
                    return(_usages);
                }

                var usage = new CommandUsage()
                {
                    Description = _description,
                    Arguments   = _handlers.OfType <Argument>(),
                    ValidFlags  = _handlers.Where(x => !(x is Argument))
                };

                return(new CommandUsage[] { usage });
            });
        }
예제 #3
0
        private void listAllCommands(HelpInput input)
        {
            var report = new TwoColumnReport("Available commands:");

            input.CommandTypes.OrderBy(CommandFactory.CommandNameFor).Each(type =>
            {
                report.Add(CommandFactory.CommandNameFor(type), CommandFactory.DescriptionFor(type));
            });

            report.Write();
        }