示例#1
0
        public void VerifyHelpData()
        {
            var config = Configuration.Configure<HelpClassTest>();
            var help = new HelpProvider();

            var result = help.GenerateModelHelp(config);

            result.SwitchDelimiter.Should().Be.EqualTo("//");
            result.Members.Count().Should().Be.EqualTo(4);
            result.HelpText.Should().Be.EqualTo("This is my console application");

            var m = result.Members.Where(h => h.Name == "Id").Single();
            m.HelpText.Should().Be.EqualTo("This is the Id");
            m.OrdinalIndex.Should().Be.EqualTo(default(int?));
            m.Switches.Should().Have.SameSequenceAs(new[] { "Id", "I" });

            m = result.Members.Where(h => h.Name == "Name").Single();
            m.HelpText.Should().Be.EqualTo("This is the name you should put in.");
            m.OrdinalIndex.Should().Be.EqualTo(default(int?));
            m.Switches.Should().Have.SameSequenceAs(new[] { "Name", "N" });

            m = result.Members.Where(h => h.Name == "Switch").Single();
            m.HelpText.Should().Be.EqualTo("Force it!");
            m.OrdinalIndex.Should().Be.EqualTo(default(int?));
            m.Switches.Should().Have.SameSequenceAs(new[] { "Switch", "S" });

            m = result.Members.Where(h => h.Name == "Date").Single();
            m.HelpText.Should().Be.EqualTo("Effective date");
            m.OrdinalIndex.Should().Be.EqualTo(0);
            m.Switches.Should().Be.Empty();
        }
示例#2
0
        public void VerifyHelpData()
        {
            var config = Configuration.Configure <HelpClassTest>();
            var help   = new HelpProvider();

            var result = help.GenerateModelHelp(config);

            result.SwitchDelimiter.Should().Be.EqualTo("//");
            result.Members.Count().Should().Be.EqualTo(4);
            result.HelpText.Should().Be.EqualTo("This is my console application");

            var m = result.Members.Where(h => h.Name == "Id").Single();

            m.HelpText.Should().Be.EqualTo("This is the Id");
            m.OrdinalIndex.Should().Be.EqualTo(default(int?));
            m.Switches.Should().Have.SameSequenceAs(new[] { "Id", "I" });

            m = result.Members.Where(h => h.Name == "Name").Single();
            m.HelpText.Should().Be.EqualTo("This is the name you should put in.");
            m.OrdinalIndex.Should().Be.EqualTo(default(int?));
            m.Switches.Should().Have.SameSequenceAs(new[] { "Name", "N" });

            m = result.Members.Where(h => h.Name == "Switch").Single();
            m.HelpText.Should().Be.EqualTo("Force it!");
            m.OrdinalIndex.Should().Be.EqualTo(default(int?));
            m.Switches.Should().Have.SameSequenceAs(new[] { "Switch", "S" });

            m = result.Members.Where(h => h.Name == "Date").Single();
            m.HelpText.Should().Be.EqualTo("Effective date");
            m.OrdinalIndex.Should().Be.EqualTo(0);
            m.Switches.Should().Be.Empty();
        }
示例#3
0
        public void VerifyHelpData()
        {
            var config = Configuration.Configure <HelpClassTest>();
            var help   = new HelpProvider();

            var result = help.GenerateModelHelp(config);

            Assert.AreEqual("//", result.SwitchDelimiter);
            Assert.AreEqual(4, result.Members.Count());
            Assert.AreEqual("This is my console application", result.HelpText);

            var m = result.Members.Where(h => h.Name == "Id").Single();

            Assert.AreEqual("This is the Id", m.HelpText);
            Assert.AreEqual(default(int?), m.OrdinalIndex);
            Assert.IsTrue(new[] { "Id", "I" }.SequenceEqual(m.Switches));

            m = result.Members.Where(h => h.Name == "Name").Single();
            Assert.AreEqual("This is the name you should put in.", m.HelpText);
            Assert.AreEqual(default(int?), m.OrdinalIndex);
            Assert.IsTrue(new[] { "Name", "N" }.SequenceEqual(m.Switches));

            m = result.Members.Where(h => h.Name == "Switch").Single();
            Assert.AreEqual("Force it!", m.HelpText);
            Assert.AreEqual(default(int?), m.OrdinalIndex);
            Assert.IsTrue(new[] { "Switch", "S" }.SequenceEqual(m.Switches));

            m = result.Members.Where(h => h.Name == "Date").Single();
            Assert.AreEqual("Effective date", m.HelpText);
            Assert.Zero(m.OrdinalIndex.Value);
            Assert.IsEmpty(m.Switches);
        }
示例#4
0
        private static void ShowHelp(IModelBindingDefinition <Options> argsConfig)
        {
            var helpProvider  = new HelpProvider();
            var help          = helpProvider.GenerateModelHelp(argsConfig);
            var helpFormatter = new ConsoleHelpFormatter();

            Console.WriteLine(helpFormatter.GetHelp(help));
            Console.ReadKey();
        }
示例#5
0
        internal static void Main(string[] args)
        {
            try
            {
                // Expand fist and then bind to Args
                var expanded = args.Select(a => parser.ParseArguments(a)).ToArray();

                var config = Args.Configuration.Configure<CommandArgs>();

                var cmds = config.AsFluent()
                                 .UsingStringComparer(StringComparer.InvariantCultureIgnoreCase)
                                 .Initialize()
                                 .CreateAndBind(expanded);

                if (args.Length < 1 || args.Length == 1 && cmds.ShowHelp)
                {
                    var help = new HelpProvider();
                    var commandsHelp = help.GenerateModelHelp<CommandArgs>(config);

                    var formatter = new Args.Help.Formatters.ConsoleHelpFormatter();
                    formatter.WriteHelp(commandsHelp, Console.Out);

                    return;
                }

                // TODO: Research for a better way to validate parameters with Args
                try
                {
                    ValidateArgs(cmds);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine();
                    Console.WriteLine("Try bootstrapper -help for more information");
                }

                Mapper.CreateMap<CommandArgs, BootStrapperArgs>()
                          .ForMember(dest => dest.Unzip, opt => opt.MapFrom(src => !String.IsNullOrEmpty(src.Unzip)))
                          .ForMember(dest => dest.UnzipTarget, opt => opt.MapFrom(src => parser.ParseArguments(src.Unzip)));

                var bootArgs = Mapper.Map<CommandArgs, BootStrapperArgs>(cmds);

                var builder = BuildContainer();

                using (var container = builder.Build())
                {
                    container.Resolve<BootStrapperManager>().Start(bootArgs);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());

                // TODO: Push error to blob storage?
            }
        }
        public static void Main(string[] args)
        {
            AppLaunchingCommandLine commandLine;
            IModelBindingDefinition <AppLaunchingCommandLine> modelBindingDefinition = null;

            try
            {
                modelBindingDefinition = Configuration.Configure <AppLaunchingCommandLine>();
                commandLine            = modelBindingDefinition.CreateAndBind(args);

                /*
                 * if (commandLine.ProductId == Guid.Empty)
                 * {
                 *  Console.WriteLine("");
                 *  Console.WriteLine("***Warning*** - no productId supplied");
                 *  Console.WriteLine("");
                 * }
                 */
            }
            catch (Exception /*exception*/)
            {
                if (modelBindingDefinition != null)
                {
                    var help      = new HelpProvider();
                    var formatter = new ConsoleHelpFormatter();

                    var sw   = new StringWriter();
                    var text = help.GenerateModelHelp(modelBindingDefinition);
                    formatter.WriteHelp(text, sw);
                    Console.Write(sw.ToString());
                }
                else
                {
                    Console.Write("Sorry - no help available!");
                }
                return;
            }

            try
            {
                Console.WriteLine("AutomationHost starting");
                using (var program = new Program(commandLine))
                {
                    Console.WriteLine("To show help, enter 'help'");
                    program.Run();
                }
            }
            catch (QuitNowPleaseException)
            {
                Console.WriteLine("Goodbye");
            }
            catch (Exception exception)
            {
                Console.WriteLine(string.Format("Exception seen {0} {1}", exception.GetType().FullName,
                                                exception.Message));
            }
        }
        public static void Main(string[] args)
        {
            AppLaunchingCommandLine commandLine;
            IModelBindingDefinition<AppLaunchingCommandLine> modelBindingDefinition = null;
            try
            {
                modelBindingDefinition = Configuration.Configure<AppLaunchingCommandLine>();
                commandLine = modelBindingDefinition.CreateAndBind(args);

                /*
                if (commandLine.ProductId == Guid.Empty)
                {
                    Console.WriteLine("");
                    Console.WriteLine("***Warning*** - no productId supplied");
                    Console.WriteLine("");
                }
                */
            }
            catch (Exception /*exception*/)
            {
                if (modelBindingDefinition != null)
                {
                    var help = new HelpProvider();
                    var formatter = new ConsoleHelpFormatter();

                    var sw = new StringWriter();
                    var text = help.GenerateModelHelp(modelBindingDefinition);
                    formatter.WriteHelp(text, sw);
                    Console.Write(sw.ToString());
                }
                else
                {
                    Console.Write("Sorry - no help available!");
                }
                return;
            }

            try
            {
                Console.WriteLine("AutomationHost starting");
                using (var program = new Program(commandLine))
                {
                    Console.WriteLine("To show help, enter 'help'");
                    program.Run();
                }
            }
            catch (QuitNowPleaseException)
            {
                Console.WriteLine("Goodbye");
            }
            catch (Exception exception)
            {
                Console.WriteLine(string.Format("Exception seen {0} {1}", exception.GetType().FullName,
                                                exception.Message));
            }
        }
示例#8
0
        public override void Execute()
        {
            base.Execute();

            var helpProvider = new HelpProvider();
            var modelHelp = helpProvider.GenerateModelHelp(_modelBindingDefinition);

            var helpFormatter = new HelpFormatter();
            helpFormatter.WriteHelp(modelHelp, System.Console.Out);
        }
示例#9
0
        public override void Execute()
        {
            base.Execute();

            var helpProvider = new HelpProvider();
            var modelHelp    = helpProvider.GenerateModelHelp(_modelBindingDefinition);

            var helpFormatter = new HelpFormatter();

            helpFormatter.WriteHelp(modelHelp, System.Console.Out);
        }
示例#10
0
        static void Main(string[] args)
        {
            var model = Args.Configuration.Configure <DeploymentArgs>();

            if (args.Length < 2)
            {
                WriteLine(@"WAWSDeploy version {0}", typeof(Program).Assembly.GetName().Version);
                var help = new HelpProvider();
                new ConsoleHelpFormatter().WriteHelp(help.GenerateModelHelp(model), Console.Out);
                return;
            }

            // parse the command line args
            var command = model.CreateAndBind(args);

            try
            {
                var webDeployHelper = new WebDeployHelper();

                webDeployHelper.DeploymentTraceEventHandler += Trace;

                WriteLine("Starting deployment...");
                DeploymentChangeSummary changeSummary = webDeployHelper.DeployContentToOneSite(
                    command.Folder,
                    command.PublishSettingsFile,
                    command.Password,
                    command.AllowUntrusted,
                    !command.DeleteExistingFiles,
                    command.TraceLevel,
                    command.WhatIf,
                    command.TargetPath,
                    command.UseChecksum,
                    command.AppOffline,
                    command.RetryAttempts,
                    command.RetryInterval,
                    command.SkipAppData,
                    command.SkipFoldersRegexps
                    );

                WriteLine("BytesCopied: {0}", changeSummary.BytesCopied);
                WriteLine("Added: {0}", changeSummary.ObjectsAdded);
                WriteLine("Updated: {0}", changeSummary.ObjectsUpdated);
                WriteLine("Deleted: {0}", changeSummary.ObjectsDeleted);
                WriteLine("Errors: {0}", changeSummary.Errors);
                WriteLine("Warnings: {0}", changeSummary.Warnings);
                WriteLine("Total changes: {0}", changeSummary.TotalChanges);
            }
            catch (Exception e)
            {
                WriteLine("Deployment failed: {0}", e.Message);
                Environment.ExitCode = 1;
            }
        }
示例#11
0
        static void Main(string[] args)
        {
            var modelBindingDefinition = Args.Configuration.Configure<RunnerCommands>();
            var command = modelBindingDefinition.CreateAndBind(args);

            var helpProvider = new HelpProvider();
            var generateModelHelp = helpProvider.GenerateModelHelp(modelBindingDefinition);

            var formatter = new ConsoleHelpFormatter();
            formatter.WriteHelp(generateModelHelp, Console.Out);

            Console.WriteLine();

            //Console.WriteLine("RunProblem: {0}", command.RunProblem.HasValue ? command.RunProblem.Value.ToString() : "No value" );
            //Console.WriteLine("Page: {0}", command.Page.HasValue ? command.Page.Value.ToString() : "No value");
        }
示例#12
0
        public static void Main(string[] args)
        {
            IModelBindingDefinition <CommandArgs> config = null;
            String errorMessage = null;
            var    showHelp     = args.Length == 0;

            try {
                config  = Configuration.Configure <CommandArgs>();
                Command = config.CreateAndBind(args);
            } catch (InvalidOperationException ex) {
                showHelp     = true;
                errorMessage = "Error: " + ex.Message;
            }

            if (showHelp)
            {
                var helpProvider = new HelpProvider();
                var help         = helpProvider.GenerateModelHelp(config);
                Console.WriteLine(help.HelpText);
                Console.WriteLine(errorMessage);
                return;
            }
            else
            {
                Console.WriteLine(@"  <!-- This tool isn't aware of inherited methods, and the binding generator will complain that the xpath isn't found. -->");
                Console.WriteLine(@"  <!-- These nodes will be ignored by the generator. -->");
            }

            var files = Directory.EnumerateFiles(Command.JavadocPath, "*.html", SearchOption.AllDirectories);

            // TODO: Optionally parse allclasses-noframe.html instead
            foreach (var file in files)
            {
                ParseFile(file); // TODO: write the attr nodes direct to metadata.xml.
            }
        }
        internal static void Main(string[] args)
        {
            try
            {
                // Expand first and then bind to Args
                var expanded = args.Select(a => parser.ParseArguments(a)).ToArray();

                var config = Args.Configuration.Configure<CommandArgs>();

                var cmds = config.AsFluent()
                    .UsingStringComparer(StringComparer.InvariantCultureIgnoreCase)
                    .UsingSwitchDelimiter("/")
                    .Initialize()
                    .CreateAndBind(expanded);

                if (args.Length < 1 || args.Length == 1 && cmds.ShowHelp)
                {
                    var help = new HelpProvider();
                    var commandsHelp = help.GenerateModelHelp<CommandArgs>(config);

                    var formatter = new Args.Help.Formatters.ConsoleHelpFormatter();
                    formatter.WriteHelp(commandsHelp, Console.Out);

                    return;
                }

                // TODO: Research for a better way to validate parameters with Args
                try
                {
                    ValidateArgs(cmds);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine();
                    Console.WriteLine("Try bootstrapper -help for more information");
                }

                //simple mapping
                var bootArgs = new BootStrapperArgs
                    {
                        Args = cmds.Args,
                        Block = cmds.Block,
                        EnableSystemProfile = cmds.EnableSystemProfile,
                        Get = cmds.Get,
                        LocalResource = cmds.LocalResource,
                        Overwrite = cmds.Overwrite,
                        Put = cmds.Put,
                        Run = cmds.Run,
                        RunAlways = cmds.RunAlways,
                        StorageConnection = cmds.StorageConnection,
                        Unzip = !String.IsNullOrWhiteSpace(cmds.Unzip),
                        UnzipTarget = cmds.Unzip
                    };

                //default to trace logger
                var logger = new TraceLogger();
                var manager = new BootStrapperManager(logger, new PackageDownloader(logger), new PackageRunner(logger),
                                                      new PackageUnzipper(logger), new PackageUploader(logger),
                                                      new PackageZipper(logger));

                manager.Start(bootArgs);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());

                // TODO: Push error to blob storage?
            }
        }
示例#14
0
 private static void ShowHelp(IModelBindingDefinition<Options> argsConfig)
 {
     var helpProvider = new HelpProvider();
     var help = helpProvider.GenerateModelHelp(argsConfig);
     var helpFormatter = new ConsoleHelpFormatter();
     Console.WriteLine(helpFormatter.GetHelp(help));
     Console.ReadKey();
 }
示例#15
0
        private static void OutputHelp(IModelBindingDefinition<ProgramOptions> configuration)
        {
            var help = new HelpProvider();
            var helpProvider = help.GenerateModelHelp(configuration);

            var consoleFormatter = new ConsoleHelpFormatter(80, 1, 5);
            Console.WriteLine(consoleFormatter.GetHelp(helpProvider));
        }