コード例 #1
0
        public string GetBriefDescription()
        {
            string description = Description == "" ? "@" + FilterDelegate.FilterName() : Description;

            List <string> options = new List <string> {
                "", ""
            };

            foreach (var arg in OptionArgs)
            {
                if (arg.StartsWith("-") && arg[1] != '-')
                {
                    options[0] = arg + ",";
                    break;
                }
            }

            foreach (var arg in OptionArgs)
            {
                if (arg.StartsWith("--"))
                {
                    options[1] = arg;
                    break;
                }
            }

            List <string> descLines = new List <string>();

            Utils.WordWrap(description, 70).ForEach(l => descLines.Add(l));
            //Utils.WordWrap(ParamDesc, 70).ForEach(l => descLines.Add(l));

            var sb = new StringBuilder();

            for (var index = 0; index < descLines.Count; index++)
            {
                var desc = index < descLines.Count ? descLines[index].Trim() : "";
                if (index == 0)
                {
                    sb.Append($"  {options[0],-5} {options[1],-26} {desc}");
                }
                else
                {
                    sb.Append($"  {"",-5} {"",-26} {desc}");
                }
                if (index < descLines.Count - 1)
                {
                    sb.AppendLine();
                }
            }

            return(sb.ToString());
        }
コード例 #2
0
        public string GetVerboseDescription()
        {
            string description = Description == "" ? "@" + FilterDelegate.FilterName() : Description;

            List <string> optLines = new List <string>(4);

            for (var i = 0; i < OptionArgs.Count; i++)
            {
                string option = OptionArgs[i] + ParamList;
                if (i != 0 && option.Length > 28 && ParamList != null)
                {
                    option = OptionArgs[i] + "=...";
                }

                List <string> argParts = Utils.ParamsWrap(option, 28);
                for (var index = 0; index < argParts.Count; index++)
                {
                    var argPart = argParts[index];
                    optLines.Add(index > 0 ? "    " + argPart : argPart);
                }
            }

            List <string> descLines = new List <string>();

            Utils.WordWrap(description, 70).ForEach(l => descLines.Add(l));
            Utils.WordWrap(ParamDesc, 70).ForEach(l => descLines.Add(l));

            var sb           = new StringBuilder();
            int lineMaxCount = descLines.Count.Max(optLines.Count);

            for (var index = 0; index < lineMaxCount; index++)
            {
                var opt  = index < optLines.Count ? optLines[index].TrimEnd() : "";
                var desc = index < descLines.Count ? descLines[index].Trim() : "";
                sb.Append($"  {opt,-31} {desc}");
                if (index < lineMaxCount - 1)
                {
                    sb.AppendLine();
                }
            }

            return(sb.ToString());
        }