Exemple #1
0
        /// <summary>
        ///  Prints help for a configurationNamespace
        /// </summary>
        /// <param name="namespaceAttribute">The configurationNamespace to print help for</param>
        /// <param name="width">The width of the console</param>
        /// <param name="indent">The indent to use</param>
        /// <param name="tw">The Textwriter to write the help to</param>
        public static void ConfigurationNamespaceHelp(CmdConfigurationNamespaceAttribute namespaceAttribute, int width, int indent = 3,
                                                      TextWriter tw = null)
        {
            tw = tw ?? Console.Out;

            tw.Write(
                CommandlineMethods.PadCentered($"{namespaceAttribute.Name}{(namespaceAttribute.IsReadonly ? " (RW)" : "")}", width));
            if (!(namespaceAttribute.LongDescription is null))
            {
                foreach (string s in namespaceAttribute.LongDescription)
                {
                    CommandlineMethods.PrintWithPotentialIndent(s, width, 0, tw);
                }
            }

            tw.Write(CommandlineMethods.PadCentered("Values", width));
            foreach (CmdConfigurationFieldAttribute valueAttribute in namespaceAttribute.ConfigurationFields)
            {
                if (valueAttribute.Description is null)
                {
                    tw.WriteLine(valueAttribute.Name);
                }
                else
                {
                    CommandlineMethods.PrintWithPotentialIndent(
                        $"{valueAttribute.Name}: {valueAttribute.Description}", width, indent, tw);
                }
            }
        }
 public ConfigurationInterpreter(CommandlineOptionInterpreter top, CmdConfigurationNamespaceAttribute root,
                                 object referenceToObject,
                                 TypeInfo typeInfoOfConfiguration, int offset = 0) : base(top, root.Name,
                                                                                          offset)
 {
     _root = root;
     _referenceToObject       = referenceToObject;
     _typeInfoOfConfiguration = typeInfoOfConfiguration;
 }
Exemple #3
0
        /// <summary>
        ///  Prints help for an fieldAttribute
        /// </summary>
        /// <param name="namespaceAttribute">The fieldAttribute to print help for</param>
        /// <param name="interpreter">The interpreter to use</param>
        /// <param name="showGenericConfigurationInfo"></param>
        public static void PrintConfigurationContextHelp(CmdConfigurationNamespaceAttribute namespaceAttribute,
                                                         BaseInterpreter interpreter,
                                                         bool showGenericConfigurationInfo = false)
        {
            if (showGenericConfigurationInfo)
            {
                ConfigurationGenericHelp(interpreter, Console.WindowWidth, interpreter.TopInterpreter.Options.DefaultIndent);
            }

            ConfigurationNamespaceHelp(namespaceAttribute, Console.WindowWidth, interpreter.TopInterpreter.Options.DefaultIndent);
        }