Beispiel #1
0
        public static string Generate(CommandModel model)
        {
            StringBuilder builder = new StringBuilder();

            // TODO: abstract away this reflection logic
            string appName = model.CliCommands.GetType().GetTypeInfo().Assembly.GetName().Name;

            builder.AppendLine($"Commands for {appName}");
            builder.AppendLine();
            builder.AppendLine($"Usage:\n{appName} [COMMAND] [COMMAND ARGUMENTS]");
            builder.AppendLine();
            builder.AppendLine($"For Command Help:\n{appName} [COMMAND] --help");
            builder.AppendLine();

            foreach (var command in model.Commands)
            {
                builder.AppendLine(GetCommandString(model, command));
                builder.AppendLine();
            }

            return(builder.ToString());
        }
        private static void ExecuteCommand <C>(C commands, string[] args) where C : BaseCliCommands
        {
            var model = new CommandModel(commands);

            model.Execute(args);
        }