예제 #1
0
        public void PrintOptions(ILogger logger, int prefixWidth, int outputWidth)
        {
            foreach (var option in configuration)
            {
                var optionText = $"  {optionPrefix}{option.Key} <{option.Key.ToUpperInvariant()}>";
                logger.WriteResult($"{optionText.PadRight(prefixWidth)}");

                var parameters  = string.Join(", ", option.Value.GetAllOptions.Value);
                var explanation = $"Allowed values: ";
                logger.WriteInfo($": {explanation}");

                var maxWidth = outputWidth - prefixWidth - explanation.Length - Environment.NewLine.Length - breakText.Length;
                var lines    = StringAndTextExtensions.Wrap(parameters, maxWidth);
                if (lines.Count == 0)
                {
                    logger.WriteLine();
                    continue;
                }

                logger.WriteLineInfo($"{lines.First().Trim(trimChars)}");
                var padding            = new string(' ', prefixWidth);
                var explanationPadding = new string(' ', explanation.Length);
                foreach (var line in lines.Skip(1))
                {
                    logger.WriteLineInfo($"{padding}{breakText}{explanationPadding}{line.Trim(trimChars)}");
                }
            }
        }
예제 #2
0
        internal void PrintOptions(int prefixWidth, int outputWidth)
        {
            foreach (var option in Configuration)
            {
                var optionText = $"  {OptionPrefix}{option.Key}=<{option.Key.ToUpperInvariant()}>";
                logger.WriteResult($"{optionText.PadRight(prefixWidth)}");

                var maxWidth = outputWidth - prefixWidth - System.Environment.NewLine.Length - BreakText.Length;
                var lines    = StringAndTextExtensions.Wrap(option.Value, maxWidth);
                if (lines.Count == 0)
                {
                    logger.WriteLine();
                    continue;
                }

                logger.WriteLineInfo($"{BreakText}{lines.First().Trim(TrimChars)}");
                var padding = new string(' ', prefixWidth);
                foreach (var line in lines.Skip(1))
                {
                    logger.WriteLineInfo($"{padding}{BreakText}{line.Trim(TrimChars)}");
                }
            }
        }