Exemple #1
0
        protected override ExtendedRichDescription GetDescription(IOperationConfiguration config)
        {
            if (string.IsNullOrWhiteSpace(config.DefaultArgument))
            {
                return(new ExtendedRichDescription(new RichDescription("PSVerify {error parsing statement}")));
            }

            var defaultArg = config.DefaultArgument;
            var longDesc   = new RichDescription();

            bool longDescInclused = false;
            var  scriptName       = LooselyQualifiedName.TryParse(defaultArg);

            if (scriptName != null)
            {
                var info = PowerShellScriptInfo.TryLoad(scriptName);
                if (!string.IsNullOrEmpty(info?.Description))
                {
                    longDesc.AppendContent(info.Description);
                    longDescInclused = true;
                }

                var listParams = new List <string>();
                foreach (var prop in config.NamedArguments)
                {
                    listParams.Add($"{prop.Key}: {prop.Value}");
                }

                foreach (var prop in config.OutArguments)
                {
                    listParams.Add($"{prop.Key} => {prop.Value}");
                }

                if (listParams.Count > 0)
                {
                    if (longDescInclused)
                    {
                        longDesc.AppendContent(" - ");
                    }

                    longDesc.AppendContent(new ListHilite(listParams));
                    longDescInclused = true;
                }
            }

            if (!longDescInclused)
            {
                longDesc.AppendContent("with no parameters");
            }

            return(new ExtendedRichDescription(
                       new RichDescription("PSVerify ", new Hilite(defaultArg)),
                       longDesc
                       ));
        }
Exemple #2
0
        public CallScriptInfo TryLoad(string name, object loadContext)
        {
            var scriptName = LooselyQualifiedName.Parse(name);
            var info       = PowerShellScriptInfo.TryLoad(scriptName, loadContext);

            if (info == null)
            {
                return(null);
            }

            return(new CallScriptInfo(
                       scriptName.ToString(),
                       info.Parameters.Select(p => new CallScriptArgument
            {
                DefaultValue = p.DefaultValue,
                Description = p.Description,
                IsBooleanOrSwitch = p.IsBooleanOrSwitch,
                IsOutput = p.IsOutput,
                Name = p.Name
            })
                       ));
        }