Ejemplo n.º 1
0
        private static NewCommand BuildNewCommand(FluentCommandLineParser parser, string[] args)
        {
            var command = new NewCommand();

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

            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>('g', "guid")
                .Callback(x => command.ProjectGuid = x)
                .SetDefault(Guid.NewGuid().ToString());

            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;
        }
Ejemplo n.º 2
0
        private static NewCommand BuildNewCommand(FluentCommandLineParser parser, string[] args)
        {
            var command = new NewCommand();

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

            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>('g', "guid")
            .Callback(x => command.ProjectGuid = x)
            .SetDefault(Guid.NewGuid().ToString());

            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);
        }