// Displays the list of templates in a table, one row per template group.
        //
        // The columns displayed are as follows:
        // Except where noted, the values are taken from the highest-precedence template in the group. The info could vary among the templates in the group, but shouldn't.
        // (There is no check that the info doesn't vary.)
        // - Template Name
        // - Short Name: displays the first short name from the highest precedence template in the group.
        // - Language: All languages supported by any template in the group are displayed, with the default language in brackets, e.g.: [C#]
        // - Tags
        private static void DisplayTemplateList(IReadOnlyCollection <ITemplateMatchInfo> templates, IEngineEnvironmentSettings environmentSettings, INewCommandInput commandInput, string defaultLanguage)
        {
            IReadOnlyCollection <TemplateGroupTableRow> groupsForDisplay = TemplateGroupDisplay.GetTemplateGroupsForListDisplay(templates, commandInput.Language, defaultLanguage);

            HelpFormatter <TemplateGroupTableRow> formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    commandInput,
                    groupsForDisplay,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.Name, LocalizableStrings.ColumnNameTemplateName, shrinkIfNeeded: true, minWidth: 15, showAlways: true)
                .DefineColumn(t => t.ShortName, LocalizableStrings.ColumnNameShortName, showAlways: true)
                .DefineColumn(t => t.Languages, out object languageColumn, LocalizableStrings.ColumnNameLanguage, NewCommandInputCli.LanguageColumnFilter, defaultColumn: true)
                .DefineColumn(t => t.Type, LocalizableStrings.ColumnNameType, NewCommandInputCli.TypeColumnFilter, defaultColumn: false)
                .DefineColumn(t => t.Author, LocalizableStrings.ColumnNameAuthor, NewCommandInputCli.AuthorColumnFilter, defaultColumn: false, shrinkIfNeeded: true, minWidth: 10)
                .DefineColumn(t => t.Classifications, out object tagsColumn, LocalizableStrings.ColumnNameTags, NewCommandInputCli.TagsColumnFilter, defaultColumn: true)

                .OrderByDescending(languageColumn, new NullOrEmptyIsLastStringComparer())
                .OrderBy(tagsColumn);

            Reporter.Output.WriteLine(formatter.Layout());
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // create Options object
            Options options = new Options();

            // add t option
            options.AddOption("t", false, "display current time");
            options.AddOption("h", false, "Display help options");
            CommandLineParser parser = new DefaultParser();
            CommandLine       cmd    = parser.Parse(options, args);

            options.AddOption("h", "help", false, "Print this usage information");
            options.AddOption("v", "verbose", false, "Print out VERBOSE information");

            OptionGroup optionGroup = new OptionGroup();

            optionGroup.AddOption(new OptionBuilder("f").HasArg(true).ArgName("filename").Build());
            optionGroup.AddOption(new OptionBuilder("m").HasArg(true).ArgName("email").Build());
            options.AddOptionGroup(optionGroup);

            if (cmd.HasOption("h"))
            {
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("x", options, true);
                return;
            }
            if (cmd.HasOption("t"))
            {
                Console.WriteLine(System.DateTime.Now);
            }
        }
        private static void DisplayResultsForPack(TemplateSourceSearchResult sourceResult, IEngineEnvironmentSettings environmentSettings, INewCommandInput commandInput, string defaultLanguage)
        {
            string sourceHeader = string.Format(LocalizableStrings.SearchResultSourceIndicator, sourceResult.SourceDisplayName);

            Reporter.Output.WriteLine(sourceHeader);
            Reporter.Output.WriteLine();

            IReadOnlyCollection <SearchResultTableRow> data = GetSearchResultsForDisplay(sourceResult, commandInput.Language, defaultLanguage);

            HelpFormatter <SearchResultTableRow> formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    commandInput,
                    data,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(r => r.TemplateGroupInfo.Name, LocalizableStrings.ColumnNameTemplateName, showAlways: true, shrinkIfNeeded: true, minWidth: 15)
                .DefineColumn(r => r.TemplateGroupInfo.ShortName, LocalizableStrings.ColumnNameShortName, showAlways: true)
                .DefineColumn(r => r.TemplateGroupInfo.Author, LocalizableStrings.ColumnNameAuthor, NewCommandInputCli.AuthorColumnFilter, defaultColumn: true, shrinkIfNeeded: true, minWidth: 10)
                .DefineColumn(r => r.TemplateGroupInfo.Languages, LocalizableStrings.ColumnNameLanguage, NewCommandInputCli.LanguageColumnFilter, defaultColumn: true)
                .DefineColumn(r => r.TemplateGroupInfo.Type, LocalizableStrings.ColumnNameType, NewCommandInputCli.TypeColumnFilter, defaultColumn: false)
                .DefineColumn(r => r.TemplateGroupInfo.Classifications, LocalizableStrings.ColumnNameTags, NewCommandInputCli.TagsColumnFilter, defaultColumn: false, shrinkIfNeeded: true, minWidth: 10)
                .DefineColumn(r => r.PackageName, out object packageColumn, LocalizableStrings.ColumnNamePackage, showAlways: true)
                .DefineColumn(r => r.PrintableTotalDownloads, LocalizableStrings.ColumnNameTotalDownloads, showAlways: true, rightAlign: true)
                .OrderBy(packageColumn);

            Reporter.Output.WriteLine(formatter.Layout());
        }
Exemple #4
0
        /// <summary>
        /// Displays the help when <paramref name="unambiguousTemplateGroup"/> contains the invokable templates with ambiguous precedence.
        /// </summary>
        /// <param name="unambiguousTemplateGroup">resolved unambiguous template group to use based on the command input</param>
        /// <param name="environmentSettings"></param>
        /// <param name="commandInput">the command input</param>
        /// <param name="installUnitDescriptors">the list of install unit descriptors</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">when <paramref name="unambiguousTemplateGroup"/>is <see cref="null"/></exception>
        /// <exception cref="ArgumentNullException">when <paramref name="commandInput"/>is <see cref="null"/></exception>
        private static CreationResultStatus DisplayAmbiguousPrecedenceError(
            TemplateGroup unambiguousTemplateGroup,
            IEngineEnvironmentSettings environmentSettings,
            INewCommandInput commandInput,
            IEnumerable <IInstallUnitDescriptor> installUnitDescriptors)
        {
            _ = unambiguousTemplateGroup ?? throw new ArgumentNullException(paramName: nameof(unambiguousTemplateGroup));
            _ = unambiguousTemplateGroup ?? throw new ArgumentNullException(paramName: nameof(commandInput));

            Reporter.Error.WriteLine(LocalizableStrings.AmbiguousTemplatesHeader.Bold().Red());
            List <AmbiguousTemplateDetails> ambiguousTemplateDetails = new List <AmbiguousTemplateDetails>();

            foreach (ITemplateMatchInfo template in unambiguousTemplateGroup.GetHighestPrecedenceInvokableTemplates(true))
            {
                ambiguousTemplateDetails.Add(new AmbiguousTemplateDetails
                {
                    TemplateIdentity       = template.Info.Identity,
                    TemplateName           = template.Info.Name,
                    TemplateShortName      = template.Info.ShortName,
                    TemplateLanguage       = template.Info.GetLanguage(),
                    TemplatePrecedence     = template.Info.Precedence,
                    TemplateAuthor         = template.Info.Author,
                    InstallationDescriptor = installUnitDescriptors?.FirstOrDefault(descriptor => descriptor.MountPointId == template.Info.ConfigMountPointId)
                });
            }

            HelpFormatter <AmbiguousTemplateDetails> formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    commandInput,
                    ambiguousTemplateDetails,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.TemplateIdentity, LocalizableStrings.ColumnNameIdentity, showAlways: true)
                .DefineColumn(t => t.TemplateName, LocalizableStrings.ColumnNameTemplateName, shrinkIfNeeded: true, minWidth: 15, showAlways: true)
                .DefineColumn(t => t.TemplateShortName, LocalizableStrings.ColumnNameShortName, showAlways: true)
                .DefineColumn(t => t.TemplateLanguage, LocalizableStrings.ColumnNameLanguage, showAlways: true)
                .DefineColumn(t => t.TemplatePrecedence.ToString(), out object prcedenceColumn, LocalizableStrings.ColumnNamePrecedence, showAlways: true)
                .DefineColumn(t => t.TemplateAuthor, LocalizableStrings.ColumnNameAuthor, showAlways: true, shrinkIfNeeded: true, minWidth: 10)
                .DefineColumn(t => t.InstallationDescriptor != null ? t.InstallationDescriptor.Identifier : string.Empty, LocalizableStrings.ColumnNamePackage, showAlways: true)
                .OrderByDescending(prcedenceColumn, new NullOrEmptyIsLastStringComparer());

            Reporter.Error.WriteLine(formatter.Layout().Bold().Red());

            string hintMessage = LocalizableStrings.AmbiguousTemplatesMultiplePackagesHint;

            if (unambiguousTemplateGroup.Templates.AllAreTheSame(t => t.Info.ConfigMountPointId))
            {
                IInstallUnitDescriptor descriptor = installUnitDescriptors?.First(descriptor => descriptor.MountPointId == unambiguousTemplateGroup.Templates.First().Info.ConfigMountPointId);
                if (descriptor?.Details?.ContainsKey("NuGetPackageId") ?? false)
                {
                    hintMessage = string.Format(LocalizableStrings.AmbiguousTemplatesSamePackageHint, descriptor.Identifier);
                }
            }

            Reporter.Error.WriteLine(hintMessage.Bold().Red());
            return(CreationResultStatus.NotFound);
        }
Exemple #5
0
        /// <summary>
        /// Print the help
        /// </summary>
        public void PrintHelp()
        {
            HelpFormatter formatter = new HelpFormatter();
            string        appName   = this.appName == null ? "App" : this.appName;

            formatter.PrintHelp(appName, this.rules);
        }
        private static async Task <CreationResultStatus> DisplayAmbiguousPrecedenceErrorAsync(
            TemplateGroup unambiguousTemplateGroup,
            IEngineEnvironmentSettings environmentSettings,
            INewCommandInput commandInput)
        {
            _ = unambiguousTemplateGroup ?? throw new ArgumentNullException(paramName: nameof(unambiguousTemplateGroup));
            _ = unambiguousTemplateGroup ?? throw new ArgumentNullException(paramName: nameof(commandInput));

            Reporter.Error.WriteLine(LocalizableStrings.AmbiguousTemplatesHeader.Bold().Red());
            List <AmbiguousTemplateDetails> ambiguousTemplateDetails = new List <AmbiguousTemplateDetails>();

            foreach (ITemplateMatchInfo template in unambiguousTemplateGroup.GetHighestPrecedenceInvokableTemplates(true))
            {
                ambiguousTemplateDetails.Add(new AmbiguousTemplateDetails
                {
                    TemplateIdentity   = template.Info.Identity,
                    TemplateName       = template.Info.Name,
                    TemplateShortNames = template.Info.ShortNameList,
                    TemplateLanguage   = template.Info.GetLanguage(),
                    TemplatePrecedence = template.Info.Precedence,
                    TemplateAuthor     = template.Info.Author ?? string.Empty,
                    TemplatePackage    = await template.Info.GetTemplatePackageAsync(environmentSettings).ConfigureAwait(false) as IManagedTemplatePackage
                });
            }

            HelpFormatter <AmbiguousTemplateDetails> formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    commandInput,
                    ambiguousTemplateDetails,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.TemplateIdentity, LocalizableStrings.ColumnNameIdentity, showAlways: true)
                .DefineColumn(t => t.TemplateName, LocalizableStrings.ColumnNameTemplateName, shrinkIfNeeded: true, minWidth: 15, showAlways: true)
                .DefineColumn(t => string.Join(",", t.TemplateShortNames), LocalizableStrings.ColumnNameShortName, showAlways: true)
                .DefineColumn(t => t.TemplateLanguage, LocalizableStrings.ColumnNameLanguage, showAlways: true)
                .DefineColumn(t => t.TemplatePrecedence.ToString(), out object prcedenceColumn, LocalizableStrings.ColumnNamePrecedence, showAlways: true)
                .DefineColumn(t => t.TemplateAuthor, LocalizableStrings.ColumnNameAuthor, showAlways: true, shrinkIfNeeded: true, minWidth: 10)
                .DefineColumn(t => t.TemplatePackage != null ? t.TemplatePackage.Identifier : string.Empty, LocalizableStrings.ColumnNamePackage, showAlways: true)
                .OrderByDescending(prcedenceColumn, new NullOrEmptyIsLastStringComparer());

            Reporter.Error.WriteLine(formatter.Layout().Bold().Red());

            string hintMessage = LocalizableStrings.AmbiguousTemplatesMultiplePackagesHint;

            if (unambiguousTemplateGroup.Templates.AllAreTheSame(t => t.Info.MountPointUri))
            {
                IManagedTemplatePackage?templatePackage = await unambiguousTemplateGroup.Templates.First().Info.GetTemplatePackageAsync(environmentSettings).ConfigureAwait(false) as IManagedTemplatePackage;

                if (templatePackage != null)
                {
                    hintMessage = string.Format(LocalizableStrings.AmbiguousTemplatesSamePackageHint, templatePackage.Identifier);
                }
            }
            Reporter.Error.WriteLine(hintMessage.Bold().Red());
            return(CreationResultStatus.NotFound);
        }
Exemple #7
0
            internal virtual void Usage()
            {
                string header = "The Secondary NameNode is a helper " + "to the primary NameNode. The Secondary is responsible "
                                + "for supporting periodic checkpoints of the HDFS metadata. " + "The current design allows only one Secondary NameNode "
                                + "per HDFS cluster.";
                HelpFormatter formatter = new HelpFormatter();

                formatter.PrintHelp("secondarynamenode", header, options, string.Empty, false);
            }
Exemple #8
0
        /// <summary>
        /// Prints this application's usage and help text to StdOut.
        /// </summary>
        private static void PrintUsageAndHelp()
        {
            var hf = new HelpFormatter();

            hf.PrintHelp(
                Assembly.GetExecutingAssembly().GetName().Name,
                Opts,
                true);
        }
Exemple #9
0
        private void PrintHelpMessage(Options options)
        {
            System.Console.Out.WriteLine("Retrieve logs for completed YARN applications.");
            HelpFormatter formatter = new HelpFormatter();

            formatter.PrintHelp("yarn logs -applicationId <application ID> [OPTIONS]", new Options
                                    ());
            formatter.SetSyntaxPrefix(string.Empty);
            formatter.PrintHelp("general options are:", options);
        }
Exemple #10
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);
        }
Exemple #11
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);
        }
Exemple #12
0
        public static void Main(string[] args)
        {
            try
            {
                System.Console.Out.WriteLine("khubla.com Paradox DB reader");

                /*
                 * options
                 */
                Options options = new Options();
                Option  oo      = Option.Builder().ArgName(FileOption).LongOpt(FileOption).Type(Sharpen.Runtime.GetClassForType
                                                                                                    (typeof(string))).HasArg().Required(true).Desc("file to read").Build();
                options.AddOption(oo);

                /*
                 * parse
                 */
                CommandLineParser parser = new DefaultParser();
                CommandLine       cmd    = null;
                try
                {
                    cmd = parser.Parse(options, args);
                }
                catch (Exception e)
                {
                    Sharpen.Runtime.PrintStackTrace(e);
                    HelpFormatter formatter = new HelpFormatter();
                    formatter.PrintHelp("posix", options);
                    System.Environment.Exit(0);
                }

                /*
                 * get file
                 */
                string filename = cmd.GetOptionValue(FileOption);
                if (null != filename)
                {
                    File inputFile = new File(filename);
                    if (inputFile.Exists())
                    {
                        DBTableFile       pdxFile           = new DBTableFile();
                        PDXReaderListener pdxReaderListener = new PDXReaderCSVListenerImpl();
                        pdxFile.Read(inputFile, pdxReaderListener);
                        System.Console.Out.WriteLine("done");
                    }
                }
            }
            catch (Exception e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
        }
        // Displays the list of templates in a table, one row per template group.
        //
        // The columns displayed are as follows
        // Note: Except language, the values are taken from one template in the group. The info could vary among the templates in the group, but shouldn't.
        // There is no check that the info doesn't vary.
        //  - Templates
        //  - Short Name
        //  - Language: All languages supported by the group are displayed, with the default language in brackets, e.g.: [C#]
        //  - Tags
        private static void DisplayTemplateList(IReadOnlyList <ITemplateMatchInfo> templates, IEngineEnvironmentSettings environmentSettings, string language, string defaultLanguage)
        {
            IReadOnlyDictionary <ITemplateInfo, string> templateGroupsLanguages = GetLanguagesForTemplateGroups(templates, language, defaultLanguage);

            HelpFormatter <KeyValuePair <ITemplateInfo, string> > formatter = HelpFormatter.For(environmentSettings, templateGroupsLanguages, 6, '-', false)
                                                                              .DefineColumn(t => t.Key.Name, LocalizableStrings.Templates)
                                                                              .DefineColumn(t => t.Key.ShortName, LocalizableStrings.ShortName)
                                                                              .DefineColumn(t => t.Value, out object languageColumn, LocalizableStrings.Language)
                                                                              .DefineColumn(t => t.Key.Classifications != null ? string.Join("/", t.Key.Classifications) : null, out object tagsColumn, LocalizableStrings.Tags)
                                                                              //.OrderByDescending(languageColumn, new NullOrEmptyIsLastStringComparer())
                                                                              .OrderBy(tagsColumn);
            //Reporter.Output.WriteLine(formatter.Layout());
        }
Exemple #14
0
 /// <summary>Outputs the formatted help to standard out</summary>
 internal virtual void OutputHelp()
 {
     if (!ShouldOutputHelp())
     {
         return;
     }
     if (source != null)
     {
         HelpFormatter hlp = new HelpFormatter();
         hlp.PrintHelp(Constants.ProgName + " " + Constants.ProgVersion, source.GetOptionList
                           ());
     }
 }
        public void CanShowUserSelectedColumns()
        {
            ITemplateEngineHost host = new TestHost
            {
                HostIdentifier = "TestRunner",
                Version        = "1.0.0.0",
                Locale         = "en-US"
            };

            IEngineEnvironmentSettings environmentSettings = new MockEngineEnvironmentSettings()
            {
                Host        = host,
                Environment = new MockEnvironment()
                {
                    ConsoleBufferWidth = 100
                }
            };

            INewCommandInput command = new MockNewCommandInput()
            {
                Columns = new List <string>()
                {
                    "column3"
                }
            };

            IEnumerable <Tuple <string, string, string> > data = new List <Tuple <string, string, string> >()
            {
                new Tuple <string, string, string>("My test data", "My test data", "Column 3 data"),
                new Tuple <string, string, string>("My test data", "My test data", "Column 3 data")
            };

            string expectedOutput = $"Column 1      Column 3     {Environment.NewLine}------------  -------------{Environment.NewLine}My test data  Column 3 data{Environment.NewLine}My test data  Column 3 data{Environment.NewLine}";

            HelpFormatter <Tuple <string, string, string> > formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    command,
                    data,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.Item1, "Column 1", showAlways: true)
                .DefineColumn(t => t.Item2, "Column 2", columnName: "column2")   //defaultColumn: true by default
                .DefineColumn(t => t.Item3, "Column 3", columnName: "column3", defaultColumn: false);

            string result = formatter.Layout();

            Assert.Equal(expectedOutput, result);
        }
Exemple #16
0
        // Displays the list of templates in a table, one row per template group.
        //
        // The columns displayed are as follows:
        // Except where noted, the values are taken from the highest-precedence template in the group. The info could vary among the templates in the group, but shouldn't.
        // (There is no check that the info doesn't vary.)
        // - Template Name
        // - Short Name: displays the first short name from the highest precedence template in the group.
        // - Language: All languages supported by any template in the group are displayed, with the default language in brackets, e.g.: [C#]
        // - Tags
        private static void DisplayTemplateList(IReadOnlyList <ITemplateMatchInfo> templates, IEngineEnvironmentSettings environmentSettings, string language, string defaultLanguage)
        {
            IReadOnlyList <TemplateGroupForListDisplay> groupsForDisplay = GetTemplateGroupsForListDisplay(templates, language, defaultLanguage);

            HelpFormatter <TemplateGroupForListDisplay> formatter = HelpFormatter.For(environmentSettings, groupsForDisplay, 6, '-', false)
                                                                    .DefineColumn(t => t.Name, LocalizableStrings.Templates)
                                                                    .DefineColumn(t => t.ShortName, LocalizableStrings.ShortName)
                                                                    .DefineColumn(t => t.Languages, out object languageColumn, LocalizableStrings.Language)
                                                                    .DefineColumn(t => t.Classifications, out object tagsColumn, LocalizableStrings.Tags)
                                                                    .OrderByDescending(languageColumn, new NullOrEmptyIsLastStringComparer())
                                                                    .OrderBy(tagsColumn);

            Reporter.Output.WriteLine(formatter.Layout());
        }
Exemple #17
0
        private void ShowHelp()
        {
            var helpFormatter = new HelpFormatter();
            var sb            = new System.Text.StringBuilder();

            sb.AppendLine("Several servers can be passed.");
            sb.AppendLine("Example:");
            sb.AppendLine("Running for one hour (60 minutes) and using COM-Port 'COM3'");
            sb.AppendLine("The used server is 192.168.1.12:8080, user: '******' and password: '******':");
            sb.AppendLine(String.Format("TeamCityWatcher -{0} 60 -{1} COM3", RunTime, Port));
            sb.AppendLine(String.Format("-{0} 192.168.1.12:8080,admin,adminadmin", Server));
            helpFormatter.PrintHelp("TeamCityWatcher", "Parameters for the TeamCityWatcher", _options, sb.ToString());
            Environment.Exit(1);
        }
Exemple #18
0
        protected static void PrintUsage(string msg, string command, Options options, string footer)
        {
            HelpFormatter formatter = new HelpFormatter()
            {
                SyntaxPrefix = ""
            };
            StringWriter wr = new StringWriter();

            wr.Write(command + " ");
            formatter.PrintUsage(wr, Int32.MaxValue, null, options);
            string usageOptions = wr.ToString().Trim();

            wr.Dispose();
            string optionsString = formatter.RenderOptions(new StringBuilder(), Int32.MaxValue, options, 0, 2).ToString();

            Allcea.PrintUsage(msg, usageOptions, optionsString, footer);
        }
        /// <summary>
        /// Parse the user-specified options, get the generic options, and modify
        /// configuration accordingly
        /// </summary>
        /// <param name="opts">Options to use for parsing args.</param>
        /// <param name="conf">Configuration to be modified</param>
        /// <param name="args">User-specified arguments</param>
        /// <exception cref="System.IO.IOException"/>
        private void ParseGeneralOptions(Options opts, Configuration conf, string[] args)
        {
            opts = BuildGeneralOptions(opts);
            CommandLineParser parser = new GnuParser();

            try
            {
                commandLine = parser.Parse(opts, PreProcessForWindows(args), true);
                ProcessGeneralOptions(conf, commandLine);
            }
            catch (ParseException e)
            {
                Log.Warn("options parsing failed: " + e.Message);
                HelpFormatter formatter = new HelpFormatter();
                formatter.PrintHelp("general options are: ", opts);
            }
        }
        public void CanShrinkMultipleColumns()
        {
            ITemplateEngineHost host = new TestHost
            {
                HostIdentifier = "TestRunner",
                Version        = "1.0.0.0",
                Locale         = "en-US"
            };

            IEngineEnvironmentSettings environmentSettings = new MockEngineEnvironmentSettings()
            {
                Host        = host,
                Environment = new MockEnvironment()
                {
                    ConsoleBufferWidth = 5 + 2 + 7 + 1,
                }
            };

            INewCommandInput command = new MockNewCommandInput();

            IEnumerable <Tuple <string, string> > data = new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("My test data", "My test data"),
                new Tuple <string, string>("My test data", "My test data")
            };

            string expectedOutput = $"Co...  Colu...{Environment.NewLine}-----  -------{Environment.NewLine}My...  My t...{Environment.NewLine}My...  My t...{Environment.NewLine}";

            HelpFormatter <Tuple <string, string> > formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    command,
                    data,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.Item1, "Column 1", shrinkIfNeeded: true, minWidth: 2)
                .DefineColumn(t => t.Item2, "Column 2", shrinkIfNeeded: true, minWidth: 2);

            string result = formatter.Layout();

            Assert.Equal(expectedOutput, result);
        }
Exemple #21
0
        public void CanRightAlign()
        {
            ITemplateEngineHost host = new TestHost
            {
                HostIdentifier = "TestRunner",
                Version        = "1.0.0.0",
                Locale         = "en-US"
            };

            IEngineEnvironmentSettings environmentSettings = new MockEngineEnvironmentSettings()
            {
                Host        = host,
                Environment = new MockEnvironment()
                {
                    ConsoleBufferWidth = 10, //less than need for data below
                }
            };

            INewCommandInput command = new MockNewCommandInput();

            IEnumerable <Tuple <string, string> > data = new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("Monday", "Wednesday"),
                new Tuple <string, string>("Tuesday", "Sunday")
            };

            string expectedOutput = $"Column 1   Column 2{Environment.NewLine}--------  ---------{Environment.NewLine}Monday    Wednesday{Environment.NewLine}Tuesday      Sunday{Environment.NewLine}";

            HelpFormatter <Tuple <string, string> > formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    command,
                    data,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.Item1, "Column 1")
                .DefineColumn(t => t.Item2, "Column 2", rightAlign: true);

            string result = formatter.Layout();

            Assert.Equal(expectedOutput, result);
        }
Exemple #22
0
        // Displays the list of templates in a table, one row per template group.
        //
        // The columns displayed are as follows:
        // Except where noted, the values are taken from the highest-precedence template in the group. The info could vary among the templates in the group, but shouldn't.
        // (There is no check that the info doesn't vary.)
        // - Template Name
        // - Short Name: displays the first short name from the highest precedence template in the group.
        // - Language: All languages supported by any template in the group are displayed, with the default language in brackets, e.g.: [C#]
        // - Tags
        private static void DisplayTemplateList(IReadOnlyCollection <IGrouping <string, ITemplateMatchInfo> > templates, IEngineEnvironmentSettings environmentSettings, string language, string defaultLanguage)
        {
            IReadOnlyCollection <TemplateGroupForListDisplay> groupsForDisplay = GetTemplateGroupsForListDisplay(templates, language, defaultLanguage);

            HelpFormatter <TemplateGroupForListDisplay> formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    groupsForDisplay,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.Name, LocalizableStrings.Templates, shrinkIfNeeded: true)
                .DefineColumn(t => t.ShortName, LocalizableStrings.ShortName)
                .DefineColumn(t => t.Languages, out object languageColumn, LocalizableStrings.Language)
                .DefineColumn(t => t.Classifications, out object tagsColumn, LocalizableStrings.Tags)
                .OrderByDescending(languageColumn, new NullOrEmptyIsLastStringComparer())
                .OrderBy(tagsColumn);

            Reporter.Output.WriteLine(formatter.Layout());
        }
        public void CanShowAllColumns()
        {
            IEngineEnvironmentSettings environmentSettings = new MockEngineEnvironmentSettings()
            {
                Environment = new MockEnvironment()
                {
                    ConsoleBufferWidth = 100
                }
            };

            INewCommandInput command = new MockNewCommandInput().WithCommandOption("--columns-all");

            IEnumerable <Tuple <string, string, string> > data = new List <Tuple <string, string, string> >()
            {
                new Tuple <string, string, string>("Column 1 data", "Column 2 data", "Column 3 data"),
                new Tuple <string, string, string>("Column 1 data", "Column 2 data", "Column 3 data")
            };

            string expectedOutput = $"Column 1       Column 2       Column 3     {Environment.NewLine}-------------  -------------  -------------{Environment.NewLine}Column 1 data  Column 2 data  Column 3 data{Environment.NewLine}Column 1 data  Column 2 data  Column 3 data{Environment.NewLine}";

            HelpFormatter <Tuple <string, string, string> > formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    command,
                    data,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.Item1, "Column 1", showAlways: true)
                .DefineColumn(t => t.Item2, "Column 2", columnName: "column2")  //defaultColumn: true by default
                .DefineColumn(t => t.Item3, "Column 3", columnName: "column3", defaultColumn: false);

            string result = formatter.Layout();

            Assert.Equal(expectedOutput, result);
        }
        public void CannotShrinkOverMinimumWidth()
        {
            IEngineEnvironmentSettings environmentSettings = new MockEngineEnvironmentSettings()
            {
                Environment = new MockEnvironment()
                {
                    ConsoleBufferWidth = 10, //less than need for data below
                }
            };

            INewCommandInput command = new MockNewCommandInput();

            IEnumerable <Tuple <string, string> > data = new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("My test data", "My test data"),
                new Tuple <string, string>("My test data", "My test data")
            };

            string expectedOutput = $"Column 1      Column 2   {Environment.NewLine}------------  -----------{Environment.NewLine}My test data  My test ...{Environment.NewLine}My test data  My test ...{Environment.NewLine}";

            HelpFormatter <Tuple <string, string> > formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    command,
                    data,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.Item1, "Column 1", shrinkIfNeeded: true, minWidth: 15)
                .DefineColumn(t => t.Item2, "Column 2", shrinkIfNeeded: true, minWidth: 8);

            string result = formatter.Layout();

            Assert.Equal(expectedOutput, result);
        }
        public void CanShrinkMultipleColumnsAndBalanceShrinking()
        {
            IEngineEnvironmentSettings environmentSettings = new MockEngineEnvironmentSettings()
            {
                Environment = new MockEnvironment()
                {
                    ConsoleBufferWidth = 6 + 2 + 6 + 1,
                }
            };

            INewCommandInput command = new MockNewCommandInput();

            IEnumerable <Tuple <string, string> > data = new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("My test data", "My test data"),
                new Tuple <string, string>("My test data", "My test data")
            };

            string expectedOutput = $"Col...  Col...{Environment.NewLine}------  ------{Environment.NewLine}My ...  My ...{Environment.NewLine}My ...  My ...{Environment.NewLine}";

            HelpFormatter <Tuple <string, string> > formatter =
                HelpFormatter
                .For(
                    environmentSettings,
                    command,
                    data,
                    columnPadding: 2,
                    headerSeparator: '-',
                    blankLineBetweenRows: false)
                .DefineColumn(t => t.Item1, "Column 1", shrinkIfNeeded: true, minWidth: 2)
                .DefineColumn(t => t.Item2, "Column 2", shrinkIfNeeded: true, minWidth: 2);

            string result = formatter.Layout();

            Assert.Equal(expectedOutput, result);
        }
Exemple #26
0
        public static int Main(string[] args)
        {
            string netConfig = null;
            string hostArg = null, portArg = null;

            StringWriter wout = new StringWriter();
            Options options = GetOptions();

            CommandLine commandLine = null;

            bool failed = false;
            bool isService = false;

            try {
                ICommandLineParser parser = new GnuParser(options);
                commandLine = parser.Parse(args);

                netConfig = commandLine.GetOptionValue("netconfig", "./network.conf");
                hostArg = commandLine.GetOptionValue("host");
                portArg = commandLine.GetOptionValue("port");
            } catch (ParseException) {
                wout.WriteLine("Error parsing arguments.");
                failed = true;
            }

            if (commandLine != null) {
                if (commandLine.HasOption("install")) {
                    try {
                        Install(commandLine);
                        Console.Out.WriteLine("Service installed succesfully.");
                        return 0;
                    } catch (Exception e) {
                        Console.Error.WriteLine("Error installing service: " + e.Message);
            #if DEBUG
                        Console.Error.WriteLine(e.StackTrace);
            #endif
                        return 1;
                    }
                }
                if (commandLine.HasOption("uninstall")) {
                    try {
                        Uninstall();
                        Console.Out.WriteLine("Service uninstalled succesfully.");
                        return 0;
                    } catch (Exception e) {
                        Console.Error.WriteLine("Error uninstalling service: " + e.Message);
            #if DEBUG
                        Console.Error.WriteLine(e.StackTrace);
            #endif
                        return 1;
                    }
                }

                isService = commandLine.HasOption("service");
            }

            if (isService) {
                CloudBClientService clientService = new CloudBClientService(commandLine);

                try {
                    if (Environment.UserInteractive) {
                        clientService.Start(args);
                        Console.Out.WriteLine("Press any key to stop...");
                        Console.Read();
                        clientService.Stop();
                    } else {
                        ServiceBase.Run(clientService);
                    }
                } catch (Exception) {
                    return 1;
                }

                return 0;
            }

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
            SetEventHandlers();

            ProductInfo libInfo = ProductInfo.GetProductInfo(typeof(PathClientService));
            ProductInfo nodeInfo = ProductInfo.GetProductInfo(typeof(PathClient));

            Console.Out.WriteLine("{0} {1} ( {2} )", nodeInfo.Title, nodeInfo.Version, nodeInfo.Copyright);
            Console.Out.WriteLine(nodeInfo.Description);
            Console.Out.WriteLine();
            Console.Out.WriteLine("{0} {1} ( {2} )", libInfo.Title, libInfo.Version, libInfo.Copyright);

            // Check arguments that can be null,
            if (netConfig == null) {
                wout.WriteLine("Error, no network configuration given.");
                failed = true;
            }

            if (portArg == null) {
                wout.WriteLine("Error, no port address given.");
                failed = true;
            }

            if (!failed) {
                //TODO: support for remote (eg. HTTP, FTP, TCP/IP) configurations)

                netConfig = NormalizeFilePath(netConfig);

                if (!File.Exists(netConfig)) {
                    wout.WriteLine("Error, node configuration file not found ({0}).", netConfig);
                    failed = true;
                }
            }

            wout.Flush();

            // If failed,
            if (failed) {
                HelpFormatter formatter = new HelpFormatter();
                if (!IsConsoleRedirected()) {
                    formatter.Width = Console.WindowWidth;
                }
                formatter.CommandLineSyntax = "mnode";
                formatter.Options = options;
                formatter.PrintHelp();
                Console.Out.WriteLine();
                Console.Out.WriteLine(wout.ToString());
                return 1;
            }

            try {
            #if DEBUG
                Console.Out.WriteLine("Retrieving network configuration from {0}", netConfig);
            #endif

                // Parse the network configuration string,
                NetworkConfigSource netConfigSource;
                using (FileStream stream = new FileStream(netConfig, FileMode.Open, FileAccess.Read, FileShare.None)) {
                    netConfigSource = new NetworkConfigSource();
                    //TODO: make it configurable ...
                    netConfigSource.LoadProperties(stream);
                }

                //TODO: support also IPv6

                // The base path,
                IPAddress host = null;
                if (hostArg != null) {
                    IPAddress[] addresses = Dns.GetHostAddresses(hostArg);
                    for (int i = 0; i < addresses.Length; i++) {
                        IPAddress address = addresses[i];
                        if (address.AddressFamily == AddressFamily.InterNetwork) {
                            host = address;
                            break;
                        }
                    }
                } else {
                    host = IPAddress.Loopback;
                }

                if (host == null) {
                    Console.Out.WriteLine("Error: couldn't determine the host address.");
                    return 1;
                }

                int port;
                if (!Int32.TryParse(portArg, out port)) {
                    Console.Out.WriteLine("Error: couldn't parse port argument: " + portArg);
                    return 1;
                }

                string storage = commandLine.GetOptionValue("storage", null);

                Console.Out.WriteLine("Path Client Service, " + host + " : " + port);
                //TODO:
                service = new TcpPathClientService(null, null, null);
                service.Init();

                waitHandle = new AutoResetEvent(false);
                waitHandle.WaitOne();
            } catch (Exception e) {
                Console.Out.WriteLine(e.Message);
                Console.Out.WriteLine(e.StackTrace);
                return 1;
            } finally {
                if (service != null)
                    service.Dispose();
            }

            return 0;
        }
        private static void ShowParameterHelp(IReadOnlyDictionary <string, string> inputParams, bool showImplicitlyHiddenParams, TemplateGroupParameterDetails parameterDetails, IEngineEnvironmentSettings environmentSettings, INewCommandInput commandInput)
        {
            IEnumerable <ITemplateParameter> filteredParams = TemplateParameterHelpBase.FilterParamsForHelp(
                parameterDetails.AllParams.ParameterDefinitions,
                parameterDetails.ExplicitlyHiddenParams,
                showImplicitlyHiddenParams,
                parameterDetails.HasPostActionScriptRunner,
                parameterDetails.ParametersToAlwaysShow);

            if (filteredParams.Any())
            {
                HelpFormatter <ITemplateParameter> formatter = new HelpFormatter <ITemplateParameter>(environmentSettings, commandInput, filteredParams, 2, null, true);

                formatter.DefineColumn(
                    param =>
                {
                    string options;
                    if (string.Equals(param.Name, "allow-scripts", StringComparison.OrdinalIgnoreCase))
                    {
                        options = "--" + param.Name;
                    }
                    else
                    {
                        // the key is guaranteed to exist
                        IList <string> variants = parameterDetails.GroupVariantsForCanonicals[param.Name].ToList();
                        options = string.Join("|", variants.Reverse());
                    }

                    return("  " + options);
                },
                    LocalizableStrings.Options
                    );

                formatter.DefineColumn(
                    delegate(ITemplateParameter param)
                {
                    StringBuilder displayValue = new StringBuilder(255);
                    displayValue.AppendLine(param.Documentation);

                    if (string.Equals(param.DataType, "choice", StringComparison.OrdinalIgnoreCase))
                    {
                        int longestChoiceLength = param.Choices.Keys.Max(x => x.Length);

                        foreach (KeyValuePair <string, ParameterChoice> choiceInfo in param.Choices)
                        {
                            displayValue.Append("    " + choiceInfo.Key.PadRight(longestChoiceLength + 4));

                            if (!string.IsNullOrWhiteSpace(choiceInfo.Value.Description))
                            {
                                displayValue.Append("- " + choiceInfo.Value.Description);
                            }

                            displayValue.AppendLine();
                        }
                    }
                    else
                    {
                        displayValue.Append(param.DataType ?? "string");
                        displayValue.AppendLine(" - " + param.Priority.ToString());
                    }

                    // determine the configured value
                    string configuredValue = null;
                    if (parameterDetails.AllParams.ResolvedValues.TryGetValue(param, out object resolvedValueObject))
                    {
                        // Set the configured value as long as it's non-empty and not the default value.
                        // If it's the default, we're not sure if it was explicitly entered or not.
                        // Below, there's a check if the user entered a value. If so, set it.
                        string resolvedValue = resolvedValueObject?.ToString() ?? string.Empty;

                        if (!string.IsNullOrEmpty(resolvedValue))
                        {
                            // bools get ToString() values of "True" & "False", but most templates use "true" & "false"
                            // So do a case-insensitive comparison on bools, case-sensitive on other values.
                            StringComparison comparisonType = string.Equals(param.DataType, "bool", StringComparison.OrdinalIgnoreCase)
                                    ? StringComparison.OrdinalIgnoreCase
                                    : StringComparison.Ordinal;

                            if (!string.Equals(param.DefaultValue, resolvedValue, comparisonType))
                            {
                                configuredValue = resolvedValue;
                            }
                        }
                    }

                    // If the resolved value is null/empty, or the default, only display the configured value if
                    // the user explicitly specified it or if it can be resolved from the DefaultIfOptionWithoutValue (or bool='true' for backwards compat).
                    if (string.IsNullOrEmpty(configuredValue))
                    {
                        bool handled = false;

                        if (parameterDetails.GroupUserParamsWithDefaultValues.Contains(param.Name))
                        {
                            if (param is IAllowDefaultIfOptionWithoutValue parameterWithNoValueDefault)
                            {
                                if (!string.IsNullOrEmpty(parameterWithNoValueDefault.DefaultIfOptionWithoutValue))
                                {
                                    configuredValue = parameterWithNoValueDefault.DefaultIfOptionWithoutValue;
                                    handled         = true;
                                }
                            }
                            else if (string.Equals(param.DataType, "bool", StringComparison.OrdinalIgnoreCase))
                            {
                                // Before the introduction of DefaultIfOptionWithoutValue, bool params were handled like this.
                                // Other param types didn't have any analogous handling.
                                configuredValue = "true";
                                handled         = true;
                            }
                        }

                        if (!handled)
                        {
                            // If the user explicitly specified the switch, the value is in the inputParams, so try to retrieve it here.
                            inputParams.TryGetValue(param.Name, out configuredValue);
                        }
                    }

                    // display the configured value if there is one
                    if (!string.IsNullOrEmpty(configuredValue))
                    {
                        string realValue = configuredValue;

                        if (parameterDetails.InvalidParams.Contains(param.Name) ||
                            (string.Equals(param.DataType, "choice", StringComparison.OrdinalIgnoreCase) &&
                             !param.Choices.ContainsKey(configuredValue)))
                        {
                            realValue = realValue.Bold().Red();
                        }
                        else if (parameterDetails.AllParams.TryGetRuntimeValue(environmentSettings, param.Name, out object runtimeVal) && runtimeVal != null)
                        {
                            realValue = runtimeVal.ToString();
                        }

                        displayValue.AppendLine(string.Format(LocalizableStrings.ConfiguredValue, realValue));
                    }

                    // display the default value if there is one
                    if (!string.IsNullOrWhiteSpace(param.DefaultValue))
                    {
                        displayValue.AppendLine(string.Format(LocalizableStrings.DefaultValue, param.DefaultValue));
                    }

                    if (param is IAllowDefaultIfOptionWithoutValue paramWithNoValueDefault &&
                        !string.IsNullOrWhiteSpace(paramWithNoValueDefault.DefaultIfOptionWithoutValue))
                    {
                        // default if option is provided without a value should not be displayed if:
                        // - it is bool parameter with "DefaultIfOptionWithoutValue": "true"
                        // - it is not bool parameter (int, string, etc) and default value coincides with "DefaultIfOptionWithoutValue"
                        if (string.Equals(param.DataType, "bool", StringComparison.OrdinalIgnoreCase))
                        {
                            if (!string.Equals(paramWithNoValueDefault.DefaultIfOptionWithoutValue, "true", StringComparison.OrdinalIgnoreCase))
                            {
                                displayValue.AppendLine(string.Format(LocalizableStrings.DefaultIfOptionWithoutValue, paramWithNoValueDefault.DefaultIfOptionWithoutValue));
                            }
                        }
                        else
                        {
                            if (!string.Equals(paramWithNoValueDefault.DefaultIfOptionWithoutValue, param.DefaultValue, StringComparison.Ordinal))
                            {
                                displayValue.AppendLine(string.Format(LocalizableStrings.DefaultIfOptionWithoutValue, paramWithNoValueDefault.DefaultIfOptionWithoutValue));
                            }
                        }
                    }

                    return(displayValue.ToString());
                },
                    string.Empty);

                Reporter.Output.WriteLine(formatter.Layout());
            }
            else
            {
                Reporter.Output.WriteLine(LocalizableStrings.NoParameters);
            }
        }
Exemple #28
0
        private static int Main(string[] args)
        {
            string nodeConfig = null, netConfig = null;
            string hostArg = null, portArg = null;

            StringWriter wout    = new StringWriter();
            Options      options = GetOptions();

            CommandLine commandLine = null;

            bool failed    = false;
            bool isService = false;

            try {
                ICommandLineParser parser = new GnuParser(options);
                commandLine = parser.Parse(args);

                nodeConfig = commandLine.GetOptionValue("nodeconfig", "./node.conf");
                netConfig  = commandLine.GetOptionValue("netconfig", "./network.conf");
                hostArg    = commandLine.GetOptionValue("host");
                portArg    = commandLine.GetOptionValue("port");
            } catch (ParseException) {
                wout.WriteLine("Error parsing arguments.");
                failed = true;
            }

            if (commandLine != null)
            {
                if (commandLine.HasOption("install"))
                {
                    try {
                        Install(commandLine);
                        Console.Out.WriteLine("Service installed succesfully.");
                        return(0);
                    } catch (Exception e) {
                        Console.Error.WriteLine("Error installing service: " + e.Message);
#if DEBUG
                        Console.Error.WriteLine(e.StackTrace);
#endif
                        return(1);
                    }
                }
                if (commandLine.HasOption("uninstall"))
                {
                    try {
                        Uninstall();
                        Console.Out.WriteLine("Service uninstalled succesfully.");
                        return(0);
                    } catch (Exception e) {
                        Console.Error.WriteLine("Error uninstalling service: " + e.Message);
#if DEBUG
                        Console.Error.WriteLine(e.StackTrace);
#endif
                        return(1);
                    }
                }

                isService = commandLine.HasOption("service");
            }

            if (isService)
            {
                MachineNodeService mnodeService = new MachineNodeService(commandLine);

                try {
                    if (Environment.UserInteractive)
                    {
                        mnodeService.Start(args);
                        Console.Out.WriteLine("Press any key to stop...");
                        Console.Read();
                        mnodeService.Stop();
                    }
                    else
                    {
                        ServiceBase.Run(mnodeService);
                    }
                } catch (Exception) {
                    return(1);
                }

                return(0);
            }

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
            SetEventHandlers();

            ProductInfo libInfo  = ProductInfo.GetProductInfo(typeof(TcpAdminService));
            ProductInfo nodeInfo = ProductInfo.GetProductInfo(typeof(MachineNode));

            Console.Out.WriteLine("{0} {1} ( {2} )", nodeInfo.Title, nodeInfo.Version, nodeInfo.Copyright);
            Console.Out.WriteLine(nodeInfo.Description);
            Console.Out.WriteLine();
            Console.Out.WriteLine("{0} {1} ( {2} )", libInfo.Title, libInfo.Version, libInfo.Copyright);

            // Check arguments that can be null,
            if (netConfig == null)
            {
                wout.WriteLine("Error, no network configuration given.");
                failed = true;
            }
            else if (nodeConfig == null)
            {
                wout.WriteLine("Error, no node configuration file given.");
                failed = true;
            }
            //if (portArg == null) {
            //    wout.WriteLine("Error, no port address given.");
            //    failed = true;
            //}

            if (!failed)
            {
                //TODO: support for remote (eg. HTTP, FTP, TCP/IP) configurations)

                nodeConfig = NormalizeFilePath(nodeConfig);
                netConfig  = NormalizeFilePath(netConfig);

                if (!File.Exists(nodeConfig))
                {
                    wout.WriteLine("Error, node configuration file not found ({0}).", nodeConfig);
                    failed = true;
                }
                else if (!File.Exists(netConfig))
                {
                    wout.WriteLine("Error, node configuration file not found ({0}).", netConfig);
                    failed = true;
                }
            }

            wout.Flush();

            // If failed,
            if (failed)
            {
                HelpFormatter formatter = new HelpFormatter();
                if (!IsConsoleRedirected())
                {
                    formatter.Width = Console.WindowWidth;
                }
                formatter.CommandLineSyntax = "mnode";
                formatter.Options           = options;
                formatter.PrintHelp();
                Console.Out.WriteLine();
                Console.Out.WriteLine(wout.ToString());
                return(1);
            }

            try {
#if DEBUG
                Console.Out.WriteLine("Retrieving node configuration from {0}", nodeConfig);
#endif

                // Get the node configuration file,
                ConfigSource nodeConfigSource = new ConfigSource();
                using (FileStream fin = new FileStream(nodeConfig, FileMode.Open, FileAccess.Read, FileShare.None)) {
                    //TODO: make it configurable ...
                    nodeConfigSource.LoadProperties(new BufferedStream(fin));
                }

#if DEBUG
                Console.Out.WriteLine("Retrieving network configuration from {0}", netConfig);
#endif

                // Parse the network configuration string,
                NetworkConfigSource netConfigSource;
                using (FileStream stream = new FileStream(netConfig, FileMode.Open, FileAccess.Read, FileShare.None)) {
                    netConfigSource = new NetworkConfigSource();
                    //TODO: make it configurable ...
                    netConfigSource.LoadProperties(stream);
                }

                string password = nodeConfigSource.GetString("network_password", null);
                if (password == null)
                {
                    Console.Out.WriteLine("Error: couldn't determine the network password.");
                    return(1);
                }

                // configure the loggers
                Logger.Init(nodeConfigSource);

                //TODO: support also IPv6

                // The base path,
                IPAddress host = null;
                if (hostArg != null)
                {
                    IPAddress[] addresses = Dns.GetHostAddresses(hostArg);
                    for (int i = 0; i < addresses.Length; i++)
                    {
                        IPAddress address = addresses[i];
                        if (address.AddressFamily == AddressFamily.InterNetwork)
                        {
                            host = address;
                            break;
                        }
                    }
                }
                else
                {
                    host = IPAddress.Loopback;
                }

                if (host == null)
                {
                    Console.Out.WriteLine("Error: couldn't determine the host address.");
                    return(1);
                }

                int port = DefaultPort;
                if (!String.IsNullOrEmpty(portArg))
                {
                    if (!Int32.TryParse(portArg, out port))
                    {
                        Console.Out.WriteLine("Error: couldn't parse port argument: " + portArg);
                        return(1);
                    }
                }

                string          storage        = commandLine.GetOptionValue("storage", null);
                IServiceFactory serviceFactory = GetServiceFactory(storage, nodeConfigSource);

                Console.Out.WriteLine("Machine Node, " + host + " : " + port);
                service        = new TcpAdminService(serviceFactory, host, port, password);
                service.Config = netConfigSource;
                service.Start();

                Console.Out.WriteLine();
                Console.Out.WriteLine();
                Console.Out.WriteLine("Press CTRL+C to quit...");

                waitHandle = new AutoResetEvent(false);
                waitHandle.WaitOne();
            } catch (Exception e) {
                Console.Out.WriteLine(e.Message);
                Console.Out.WriteLine(e.StackTrace);
                return(1);
            } finally {
                if (service != null)
                {
                    service.Dispose();
                }
            }

            return(0);
        }
Exemple #29
0
 protected static void PrintUsage(string msg, string command, Options options, string footer)
 {
     HelpFormatter formatter = new HelpFormatter() { SyntaxPrefix = "" };
     StringWriter wr = new StringWriter();
     wr.Write(command + " ");
     formatter.PrintUsage(wr, Int32.MaxValue, null, options);
     string usageOptions = wr.ToString().Trim();
     wr.Dispose();
     string optionsString = formatter.RenderOptions(new StringBuilder(), Int32.MaxValue, options, 0, 2).ToString();
     Allcea.PrintUsage(msg, usageOptions, optionsString, footer);
 }
        static void Main(string[] args)
        {
            //Handles early exits
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
            //Loads embedded DLLs into EXE if they don't load automatically
            AppDomain.CurrentDomain.AssemblyResolve += (sender, arguments) => {
                string resourceName = "AssemblyLoadingAndReflection." +
                                      new AssemblyName(arguments.Name).Name + ".dll";
                using (var stream = Assembly.GetExecutingAssembly()
                                    .GetManifestResourceStream(resourceName)) {
                    byte[] assemblyData = new byte[stream.Length];
                    stream.Read(assemblyData, 0, assemblyData.Length);
                    return(Assembly.Load(assemblyData));
                }
            };

            //Application initialization

            webStringUtils = new WebStringUtils(getAppFolder());
            objSaveUtils   = new ObjSaveUtils(getAppFolder() + '/');
            //Help
            //Options options = new Options();
            Options options = new Options();

            options.AddOption(new Option("h", "help", false, "display this help dialog"));
            options.AddOption(new Option("ph", "pattern help", false, "help with the -p command"));
            options.AddOption(new Option("v", "verbose", false, "verbose mode"));
            //options.AddOptionGroup(helpOptions);
            //Crawl options
            options.AddOption(new Option("dc", "dont crawl", false, "do not execute crawl. (for the purpose of using other utilities only)"));
            options.AddOption(new Option("vi", "visited", false, "print visited pages a after completion (n.i.)"));
            options.AddOption(new Option("ul", "unlock", false, "unlocks crawler from target domain"));
            options.AddOption(new Option("bc", "backcrawl", false, "deep copy, enables discovery of hidden pages (slow)"));
            options.AddOption(new Option("p", "pattern", true, "regex pattern for restricting pages"));
            options.AddOption(new Option("d", "depth", true, "depth of the search (default 10)"));
            options.AddOption(new Option("c", "courtesy", true, "delay between page loads, in milliseconds"));
            options.AddOption(new Option("t", "threads", true, "number of allowed threads. More threads = more aggressive (must be 2+)"));
            options.AddOption(new Option("i", "iterative", true, "scans urls iteratively in the form of url/1,2.. starting at <param>"));
            options.AddOption(new Option("id", "iterative depth", true, "Depth to scan to at each step of the iteration"));
            //File options
            options.AddOption(new Option("O", "overwrite", false, "overwrite files when scan starts"));
            Option downloadImages = new Option("di", "images", true, "download images while crawling (takes regex for filtering)");

            downloadImages.OptionalArg  = true;
            downloadImages.NumberOfArgs = 1;
            options.AddOption(downloadImages);
            Option downloadText = new Option("dt", "text", false, "download text bodies for analyzation <tag, regex>");

            downloadText.OptionalArg    = true;
            downloadText.NumberOfArgs   = 2;
            downloadText.ValueSeparator = ' ';
            options.AddOption(downloadText);
            options.AddOption(new Option("il", "include link", false, "include links to the parent page in text files"));
            options.AddOption(new Option("g", "gallery", false, "only download files to one folder"));
            options.AddOption(new Option("o", "output", true, "output location (defaults to exe location)"));
            options.AddOption(new Option("l", "load", true, "load data from previous scan, named <param>"));
            //Database options
            options.AddOption(new Option("dbl", "database links", false, "Save visited links into the DB, with tags defined by -dt"));
            options.AddOption(new Option("dbi", "database images", false, "Save image locations to database, with tags defined by -dt"));
            options.AddOption(new Option("ddh", "HTML", false, "don't download HTML while crawling"));
            options.AddOption(new Option("dbc", "database check", false, "Check the database to prevent duplicate entries (slow)"));
            options.AddOption(new Option("dbip", "database ip", true, "the IP address of the database to dump to"));
            //Data processing
            options.AddOption(new Option("m", "markov", true, "generate a markov chain of <param> prefix Length and saves it."));
            options.AddOption(new Option("mp", "print markov", true, "prints out [param] sentences from the chain (Must use -g)"));
            //Attempts to parse args
            try {
                ICommandLineParser parser = new PosixParser();
                //Help options
                CommandLine   helpCmd       = parser.Parse(options, args);
                HelpFormatter helpFormatter = new HelpFormatter();
                helpFormatter.Width       = 100;
                helpFormatter.DescPadding = 0x1;
                //string helpHeader = "\nSKS Web crawler/info extractor v0.1";
                string helpHeader = "\nSKS Web crawler/info extractor v0.1";
                string helpFooter = "\nExample Usage: java -jar [JARNAME] http://pornhub.com -di -d 5"
                                    + "\nSite Image Gallery: [URL] -di -ddh -g"
                                    + "\nFullsize gallery of 4chan thread: [URL] -di ^((?!s.).)*$ -ddh -g -p .*/((?!#[spq]).)*"
                                    + "\nSankaku tags on posts with urls: [URL] -g -il -ddh -dt title (.*)(/post/show/)(.*) -O -c 1000 -d 3"
                                    + "\nIterative booru tag crawl: [BASEURL] -g -il -ddh -dt title -O -c 1000 -d 1000 -i <startpage>"
                                    + "\nMarkov chain from 4chan board: [URL] -t 10 -d 15 -dt .post .* -m 2 -g -ddh -O -mp 40"
                                    + "\nInsert images into database with tags: [BOORUURL] -g -t 10 -di .*[/](_images/).* -ddh -d 10 -O -p .*[/]post/.* -ul -dt title -dbi";
                if (helpCmd.HasOption("ph"))
                {
                    Console.WriteLine("\n-p and -i take a regular exp. as an argument, searching all URLs"
                                      + "\nthat match the pattern. I.E., \"test.com/page \" would "
                                      + "\nmatch \"test.com/page/page2\". To test for any subdomain,"
                                      + "\nthe following pattern would operate on [anything].test.com:"
                                      + "\nhttps?://([^/.]+[.])*test.com(.*)");
                    return;
                }
                data.verbose = helpCmd.HasOption("v");
                //Crawl options
                CommandLine crawlCmd = parser.Parse(options, args);

                if (args.Length > 0)
                {
                    data.startURL = args[0];
                }
                data.backCrawl      = crawlCmd.HasOption("bc");
                data.iterative      = crawlCmd.HasOption("i");
                shouldCrawl         = !crawlCmd.HasOption("dc");
                data.iteratorStart  = Convert.ToInt32(crawlCmd.GetOptionValue("i", "0"));
                data.iterativeDepth = Convert.ToInt32(crawlCmd.GetOptionValue("id", "0"));
                data.crawlPattern   = crawlCmd.GetOptionValue("p", ".*");
                data.maxDepth       = Convert.ToInt32(crawlCmd.GetOptionValue("d", "5"));
                data.delay          = Convert.ToInt32(crawlCmd.GetOptionValue("c", "0"));
                crawlThreadExecutor = new LimitedConcurrencyLevelTaskScheduler(Convert.ToInt32(crawlCmd.GetOptionValue("t", "2")));
                crawlThreadFactory  = new TaskFactory(crawlThreadExecutor);
                crawlLocked         = !crawlCmd.HasOption("ul");

                //File options
                CommandLine fileCmd = parser.Parse(options, args);
                data.overwrite      = fileCmd.HasOption("O");
                data.downloadImages = fileCmd.HasOption("di");
                data.imagePattern   = fileCmd.GetOptionValue("di", "");
                data.downloadText   = fileCmd.HasOption("dt");
                data.downloadHTML   = !fileCmd.HasOption("ddh");
                data.gallery        = fileCmd.HasOption("g");

                if (data.downloadText)
                {
                    string[] imageOptions = fileCmd.GetOptionValues("dt");
                    //textTag = cmd.GetOptionValue("dt", null);
                    data.textTag = imageOptions[0];
                    try {
                        data.textPattern = imageOptions[1];
                    } catch (Exception) {
                        data.textPattern = "";
                    }
                    data.includeLinks = fileCmd.HasOption("il");
                }
                if (fileCmd.HasOption("l"))
                {
                    saveFile = fileCmd.GetOptionValue("l");
                    //Loads the chain
                    if (fileCmd.HasOption("m"))
                    {
                        markovChain = (MarkovChain)objSaveUtils.LoadObject("markov_" + saveFile, typeof(MarkovChain));
                    }
                    //Loads the tries
                    data.urlTrie    = (WebTrie)objSaveUtils.LoadObject("visitedTrie_" + saveFile, typeof(WebTrie));
                    data.assistTrie = (WebTrie)objSaveUtils.LoadObject("assistTrie_" + saveFile, typeof(WebTrie));
                    data.mediaTrie  = (WebTrie)objSaveUtils.LoadObject("assistTrie_" + saveFile, typeof(WebTrie));
                }
                else
                {
                    if (args.Length > 0)
                    {
                        saveFile = webStringUtils.UnFuck(args[0]);
                    }
                    //If not loading chain from file, create new chain
                    if (fileCmd.HasOption("m"))
                    {
                        markovChain = new MarkovChain(Convert.ToInt32(fileCmd.GetOptionValue("m", "3")));
                    }
                    //Attempts to automatically load file name
                    try {
                        data.urlTrie    = (WebTrie)objSaveUtils.LoadObject("visitedTrie_" + saveFile, typeof(WebTrie));
                        data.assistTrie = (WebTrie)objSaveUtils.LoadObject("assistTrie_" + saveFile, typeof(WebTrie));
                        data.mediaTrie  = (WebTrie)objSaveUtils.LoadObject("assistTrie_" + saveFile, typeof(WebTrie));
                    } catch (Exception) {
                        //Generate tries if not loadable
                        data.urlTrie    = new WebTrie();
                        data.assistTrie = new WebTrie();
                        data.mediaTrie  = new WebTrie();
                    }
                }
                data.outputFolder = fileCmd.GetOptionValue("o", getAppFolder()) + "CrawlResults\\";

                //Database options
                CommandLine dbCmd = parser.Parse(options, args);
                if (dbCmd.HasOption("dbip"))
                {
                    TagDBDriver.instantiateDB(dbCmd.GetOptionValue("dbip"));
                    data.dataBaseImages = dbCmd.HasOption("dbi");
                    data.dataBaseLinks  = dbCmd.HasOption("dbl");
                    data.dataBaseCheck  = dbCmd.HasOption("dbc");
                }

                //Data processing options
                CommandLine dpCmd = parser.Parse(options, args);
                printMarkov     = dpCmd.HasOption("mp");
                markovSentences = Convert.ToInt32(dpCmd.GetOptionValue("mp", "0"));

                if (helpCmd.HasOption("h") || args.Length == 0)
                {
                    printHelp();
                    return;
                }
            } catch (Exception exception) {
                Console.WriteLine("Invalid arguments or parameters. use -h for help (" + exception + ")");
                return;
            }
            //instantiates trie

            //creates regex for site locking
            if (crawlLocked)
            {
                string regexURL = Regex.Replace(args[0], "https?://", "");
                data.crawlDomain = "https?://([^/.]+[.])*" + regexURL + "(.*)";
            }
            else
            {
                data.crawlDomain = ".*";
            }

            try {
                Crawl(args[0], data);
            } catch (Exception e) {
                Console.WriteLine("Scan aborted: " + e);
            }
            // System.exit(0);
        }
 /// <summary>
 /// Print the help
 /// </summary>
 public void PrintHelp() 
 {
     HelpFormatter formatter = new HelpFormatter();
     string appName = this.appName == null ? "App" : this.appName;
     formatter.PrintHelp(appName, this.rules);
 }
Exemple #32
0
 /// <summary>
 /// Prints this application's usage and help text to StdOut.
 /// </summary>
 private static void PrintUsageAndHelp()
 {
     var hf = new HelpFormatter();
     hf.PrintHelp(
         Assembly.GetExecutingAssembly().GetName().Name,
         Opts,
         true);
 }
Exemple #33
0
        /// <summary>Print JMXGet usage information</summary>
        internal static void PrintUsage(Options opts)
        {
            HelpFormatter formatter = new HelpFormatter();

            formatter.PrintHelp("jmxget options are: ", opts);
        }
 private void ShowHelp()
 {
     var helpFormatter = new HelpFormatter();
     var sb = new System.Text.StringBuilder();
     sb.AppendLine("Several servers can be passed.");
     sb.AppendLine("Example:");
     sb.AppendLine("Running for one hour (60 minutes) and using COM-Port 'COM3'");
     sb.AppendLine("The used server is 192.168.1.12:8080, user: '******' and password: '******':");
     sb.AppendLine(String.Format("TeamCityWatcher -{0} 60 -{1} COM3", RunTime, Port));
     sb.AppendLine(String.Format("-{0} 192.168.1.12:8080,admin,adminadmin", Server));
     helpFormatter.PrintHelp("TeamCityWatcher", "Parameters for the TeamCityWatcher", _options, sb.ToString());
     Environment.Exit(1);
 }
Exemple #35
0
 /// <exception cref="Org.Apache.Commons.Cli.ParseException"/>
 private void ProcessOptions(CommandLine line, Options opts)
 {
     // --help -h and --version -V must be processed first.
     if (line.HasOption('h'))
     {
         HelpFormatter formatter = new HelpFormatter();
         System.Console.Out.WriteLine("TFile and SeqFile benchmark.");
         System.Console.Out.WriteLine();
         formatter.PrintHelp(100, "java ... TestTFileSeqFileComparison [options]", "\nSupported options:"
                             , opts, string.Empty);
         return;
     }
     if (line.HasOption('c'))
     {
         compress = line.GetOptionValue('c');
     }
     if (line.HasOption('d'))
     {
         dictSize = System.Convert.ToInt32(line.GetOptionValue('d'));
     }
     if (line.HasOption('s'))
     {
         fileSize = long.Parse(line.GetOptionValue('s')) * 1024 * 1024;
     }
     if (line.HasOption('f'))
     {
         format = line.GetOptionValue('f');
     }
     if (line.HasOption('i'))
     {
         fsInputBufferSize = System.Convert.ToInt32(line.GetOptionValue('i'));
     }
     if (line.HasOption('o'))
     {
         fsOutputBufferSize = System.Convert.ToInt32(line.GetOptionValue('o'));
     }
     if (line.HasOption('k'))
     {
         keyLength = System.Convert.ToInt32(line.GetOptionValue('k'));
     }
     if (line.HasOption('v'))
     {
         valueLength = System.Convert.ToInt32(line.GetOptionValue('v'));
     }
     if (line.HasOption('b'))
     {
         minBlockSize = System.Convert.ToInt32(line.GetOptionValue('b')) * 1024;
     }
     if (line.HasOption('r'))
     {
         rootDir = line.GetOptionValue('r');
     }
     if (line.HasOption('S'))
     {
         seed = long.Parse(line.GetOptionValue('S'));
     }
     if (line.HasOption('w'))
     {
         string          min_max = line.GetOptionValue('w');
         StringTokenizer st      = new StringTokenizer(min_max, " \t,");
         if (st.CountTokens() != 2)
         {
             throw new ParseException("Bad word length specification: " + min_max);
         }
         minWordLen = System.Convert.ToInt32(st.NextToken());
         maxWordLen = System.Convert.ToInt32(st.NextToken());
     }
     if (line.HasOption('x'))
     {
         string strOp = line.GetOptionValue('x');
         if (strOp.Equals("r"))
         {
             op = OpRead;
         }
         else
         {
             if (strOp.Equals("w"))
             {
                 op = OpCreate;
             }
             else
             {
                 if (strOp.Equals("rw"))
                 {
                     op = OpCreate | OpRead;
                 }
                 else
                 {
                     throw new ParseException("Unknown action specifier: " + strOp);
                 }
             }
         }
     }
     proceed = true;
 }
Exemple #36
0
        private static void ShowParameterHelp(IReadOnlyDictionary <string, string> inputParams, bool showImplicitlyHiddenParams, TemplateGroupParameterDetails parameterDetails, IEngineEnvironmentSettings environmentSettings)
        {
            if (!string.IsNullOrEmpty(parameterDetails.AdditionalInfo))
            {
                Reporter.Error.WriteLine(parameterDetails.AdditionalInfo.Bold().Red());
                Reporter.Output.WriteLine();
            }

            IEnumerable <ITemplateParameter> filteredParams = TemplateParameterHelpBase.FilterParamsForHelp(parameterDetails.AllParams.ParameterDefinitions, parameterDetails.ExplicitlyHiddenParams,
                                                                                                            showImplicitlyHiddenParams, parameterDetails.HasPostActionScriptRunner, parameterDetails.ParametersToAlwaysShow);

            if (filteredParams.Any())
            {
                HelpFormatter <ITemplateParameter> formatter = new HelpFormatter <ITemplateParameter>(environmentSettings, filteredParams, 2, null, true);

                formatter.DefineColumn(
                    param =>
                {
                    string options;
                    if (string.Equals(param.Name, "allow-scripts", StringComparison.OrdinalIgnoreCase))
                    {
                        options = "--" + param.Name;
                    }
                    else
                    {
                        // the key is guaranteed to exist
                        IList <string> variants = parameterDetails.GroupVariantsForCanonicals[param.Name].ToList();
                        options = string.Join("|", variants.Reverse());
                    }

                    return("  " + options);
                },
                    LocalizableStrings.Options
                    );

                formatter.DefineColumn(delegate(ITemplateParameter param)
                {
                    StringBuilder displayValue = new StringBuilder(255);
                    displayValue.AppendLine(param.Documentation);

                    if (string.Equals(param.DataType, "choice", StringComparison.OrdinalIgnoreCase))
                    {
                        int longestChoiceLength = param.Choices.Keys.Max(x => x.Length);

                        foreach (KeyValuePair <string, string> choiceInfo in param.Choices)
                        {
                            displayValue.Append("    " + choiceInfo.Key.PadRight(longestChoiceLength + 4));

                            if (!string.IsNullOrWhiteSpace(choiceInfo.Value))
                            {
                                displayValue.Append("- " + choiceInfo.Value);
                            }

                            displayValue.AppendLine();
                        }
                    }
                    else
                    {
                        displayValue.Append(param.DataType ?? "string");
                        displayValue.AppendLine(" - " + param.Priority.ToString());
                    }

                    // display the configured value if there is one
                    string configuredValue = null;
                    if (parameterDetails.AllParams.ResolvedValues.TryGetValue(param, out object resolvedValueObject))
                    {
                        string resolvedValue = resolvedValueObject as string;

                        if (!string.IsNullOrEmpty(resolvedValue) &&
                            !string.IsNullOrEmpty(param.DefaultValue) &&
                            !string.Equals(param.DefaultValue, resolvedValue))
                        {
                            configuredValue = resolvedValue;
                        }
                    }

                    if (string.IsNullOrEmpty(configuredValue))
                    {
                        // this will catch when the user inputs the default value. The above deliberately skips it on the resolved values.
                        if (string.Equals(param.DataType, "bool", StringComparison.OrdinalIgnoreCase) &&
                            parameterDetails.GroupUserParamsWithDefaultValues.Contains(param.Name))
                        {
                            configuredValue = "true";
                        }
                        else
                        {
                            inputParams.TryGetValue(param.Name, out configuredValue);
                        }
                    }

                    if (!string.IsNullOrEmpty(configuredValue))
                    {
                        string realValue = configuredValue;

                        if (parameterDetails.InvalidParams.Contains(param.Name) ||
                            (string.Equals(param.DataType, "choice", StringComparison.OrdinalIgnoreCase) &&
                             !param.Choices.ContainsKey(configuredValue)))
                        {
                            realValue = realValue.Bold().Red();
                        }
                        else if (parameterDetails.AllParams.TryGetRuntimeValue(environmentSettings, param.Name, out object runtimeVal) && runtimeVal != null)
                        {
                            realValue = runtimeVal.ToString();
                        }

                        displayValue.AppendLine(string.Format(LocalizableStrings.ConfiguredValue, realValue));
                    }

                    // display the default value if there is one
                    if (!string.IsNullOrEmpty(param.DefaultValue))
                    {
                        displayValue.AppendLine(string.Format(LocalizableStrings.DefaultValue, param.DefaultValue));
                    }

                    return(displayValue.ToString());
                }, string.Empty);

                Reporter.Output.WriteLine(formatter.Layout());
            }
            else
            {
                Reporter.Output.WriteLine(LocalizableStrings.NoParameters);
            }
        }
Exemple #37
0
        public void Man()
        {
            String cmdLine =
                    "man [-c|-f|-k|-w|-tZT device] [-adlhu7V] [-Mpath] [-Ppager] [-Slist] " +
                            "[-msystem] [-pstring] [-Llocale] [-eextension] [section] page ...";
            Options options = new Options().
                    AddOption("a", "all", false, "find all matching manual pages.").
                    AddOption("d", "debug", false, "emit debugging messages.").
                    AddOption("e", "extension", false, "limit search to extension type 'extension'.").
                    AddOption("f", "whatis", false, "equivalent to whatis.").
                    AddOption("k", "apropos", false, "equivalent to apropos.").
                    AddOption("w", "location", false, "print physical location of man page(s).").
                    AddOption("l", "local-file", false, "interpret 'page' argument(s) as local filename(s)").
                    AddOption("u", "update", false, "force a cache consistency check.").
                //FIXME - should generate -r,--prompt string
                    AddOption("r", "prompt", true, "provide 'less' pager with prompt.").
                    AddOption("c", "catman", false, "used by catman to reformat out of date cat pages.").
                    AddOption("7", "ascii", false, "display ASCII translation or certain latin1 chars.").
                    AddOption("t", "troff", false, "use troff format pages.").
                //FIXME - should generate -T,--troff-device device
                    AddOption("T", "troff-device", true, "use groff with selected device.").
                    AddOption("Z", "ditroff", false, "use groff with selected device.").
                    AddOption("D", "default", false, "reset all options to their default values.").
                //FIXME - should generate -M,--manpath path
                    AddOption("M", "manpath", true, "set search path for manual pages to 'path'.").
                //FIXME - should generate -P,--pager pager
                    AddOption("P", "pager", true, "use program 'pager' to display output.").
                //FIXME - should generate -S,--sections list
                    AddOption("S", "sections", true, "use colon separated section list.").
                //FIXME - should generate -m,--systems system
                    AddOption("m", "systems", true, "search for man pages from other unix system(s).").
                //FIXME - should generate -L,--locale locale
                    AddOption("L", "locale", true, "define the locale for this particular man search.").
                //FIXME - should generate -p,--preprocessor string
                    AddOption("p", "preprocessor", true, "string indicates which preprocessor to run.\n" +
                             " e - [n]eqn  p - pic     t - tbl\n" +
                             " g - grap    r - refer   v - vgrind").
                    AddOption("V", "version", false, "show version.").
                    AddOption("h", "help", false, "show this usage message.");

            HelpFormatter hf = new HelpFormatter();
            hf.PrintHelp(options, new HelpSettings {CommandLineSyntax = cmdLine}, Console.Out, false);
        }