Example #1
0
        private static AlterCommand BuildAlterCommand(FluentCommandLineParser parser, string[] args)
        {
            var command = new AlterCommand();

            parser
            .Setup <string>('n', "name")
            .Callback(x => command.Name = x)
            .Required();

            parser
            .Setup <string>('s', "solution")
            .Callback(x => command.Solution = x);

            parser
            .Setup <string>('t', "template")
            .Callback(x => command.Template = x)
            .Required();

            parser
            .Setup <string>('l', "location")
            .Callback(x => command.Location = x)
            .SetDefault(Environment.CurrentDirectory);

            parser
            .Setup <string>('p', "templatepaths")
            .Callback(x => command.TemplatePaths.AddRange((x ?? "").Split(';').Where(y => !string.IsNullOrEmpty(y))));

            parser
            .Setup <string>('o', "output")
            .Callback(x => command.LogTo = x);

            parser.Parse(args);

            command.TemplatePaths.Add(Path.Combine(command.Location, "Templates"));
            command.TemplatePaths.Add(Path.Combine(
                                          Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "Templates"));

            return(command);
        }
        private static AlterCommand BuildAlterCommand(FluentCommandLineParser parser, string[] args)
        {
            var command = new AlterCommand();

            parser
                .Setup<string>('n', "name")
                .Callback(x => command.Name = x)
                .Required();

            parser
                .Setup<string>('s', "solution")
                .Callback(x => command.Solution = x);

            parser
                .Setup<string>('t', "template")
                .Callback(x => command.Template = x)
                .Required();

            parser
                .Setup<string>('l', "location")
                .Callback(x => command.Location = x)
                .SetDefault(Environment.CurrentDirectory);

            parser
                .Setup<string>('p', "templatepaths")
                .Callback(x => command.TemplatePaths.AddRange((x ?? "").Split(';').Where(y => !string.IsNullOrEmpty(y))));

            parser
                .Setup<string>('o', "output")
                .Callback(x => command.LogTo = x);

            parser.Parse(args);

            command.TemplatePaths.Add(Path.Combine(command.Location, "Templates"));
            command.TemplatePaths.Add(Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "Templates"));

            return command;
        }