コード例 #1
0
        private string FormatUsage(ICommandHelp commandHelp)
        {
            var requiredArgs = new StringBuilder();

            _typeInfoParser.GetArguments(commandHelp.CommandType)
            .Where(item => item.Required)
            .ForEach(item => requiredArgs.AppendFormat("<{0}>", item.Name.PascalCaseToWords().ToLower()));

            return(string.Format("`usage: crane {0} {1}`", commandHelp.CommandName, requiredArgs));
        }
コード例 #2
0
        public void can_retrieve_command_arguments_from_a_type_with_required_arguments(ICommandTypeInfoParser infoParser, IEnumerable <ICommandArgument> result)
        {
            "Give I have a command type info parser"
            ._(() => infoParser = ServiceLocator.Resolve <CommandTypeInfoParser>());

            "When I parse the arguments"
            ._(() => result = infoParser.GetArguments(typeof(Init)));

            "It should retreive them"
            ._(() => result.Should().NotBeNull());

            "It should have the correct argument name"
            ._(() => result.First().Name.Should().Be("ProjectName"));

            "It should have the correct number of required arguments"
            ._(() => result.First().Required.Should().BeTrue());
        }