public ProgramOutput(CommandLineParameters parameters)
 {
     if (!parameters.Quiet)
     {
         _outputs.Add(new ConsoleOutput());
     }
 }
Пример #2
0
        public void RequiredValueShouldThrowIfNotParsedYet()
        {
            var parms   = new CommandLineParameters();
            var version = parms.Required <string>("version");

            Assert.That(() => version.Value, Throws.Exception);
        }
 public ProgramOutput(CommandLineParameters parameters)
 {
     if (!parameters.Quiet)
     {
         _outputs.Add(new ConsoleOutput());
     }
 }
Пример #4
0
        public void DefaultValueShouldReturnIfNotParsed()
        {
            var parms   = new CommandLineParameters();
            var version = parms.Default("version", "0.2");

            Assert.That(version.Value, Is.EqualTo("0.2"));
        }
Пример #5
0
        public void AllCommandsFound()
        {
            var types = LoadTypes();
            var io    = InputControl.Default();

            Assert.AreEqual(6, types.Count());

            foreach (var type in types)
            {
                var attr = type.GetCustomAttribute <CommandLineCommandAttribute>();

                Assert.IsNotNull(attr);

                Assert.IsNotNull(attr.Command);
                Assert.IsNotNull(attr.Description);

                var commandLine = CommandLineParameters.Parse(attr.Command);

                Assert.IsNotNull(commandLine);

                io.Writer = new StringWriter();

                var command = commandLine.CreateCommandExecutor(io);
                Assert.IsNotNull(command);

                command.DisplayHelp();

                Assert.IsTrue(!string.IsNullOrWhiteSpace(io.Writer.ToString()));
                Assert.IsTrue(io.Writer.ToString().Contains(attr.Command));
            }
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <b>BaseOperation</b> class.
 /// </summary>
 /// <param name="parameters"></param>
 /// <exception cref="ArgumentNullException">If <paramref name="parameters"/> is null.</exception>
 protected BaseOperation(CommandLineParameters parameters)
 {
     if (parameters == null) {
         throw new ArgumentNullException("parameters");
     }
     _parameters = parameters;
 }
        public async Task DestroyExecutes()
        {
            using (var tmpCacheFile = new TemporaryFile())
            {
                var parameters = CommandLineParameters.Parse($"kdestroy --cache {tmpCacheFile.File}");

                var io = new InputControl
                {
                    Clear     = () => { },
                    HookCtrlC = hook => { },
                    Writer    = new StringWriter()
                };

                var command = (KerberosDestroyCommand)parameters.CreateCommandExecutor(io);

                Assert.IsNotNull(command);

                await command.Execute();

                var result = io.Writer.ToString();

                Assert.IsTrue(result.Contains("Cache file has been deleted."));

                var exists = File.Exists(tmpCacheFile.File);

                Assert.IsFalse(exists);
            }
        }
Пример #8
0
        public void Run(string[] args, MethodInfo getTargetsMethod)
        {
            var parameters = new CommandLineParameters();

            try {
                Dictionary<string, ITask> targets = GetTargetsFromAssembly(getTargetsMethod, parameters);

                var parsedParameters = ParseCommandLineArguments(args);

                string[] buildArguments = parsedParameters.RemainingArguments;

                if (buildArguments.Length >= 2) {
                    InterpretParameters(parameters, parsedParameters, _bounce);

                    string command = buildArguments[0];
                    IEnumerable<string> targetsToBuild = TargetsToBuild(buildArguments);

                    BuildTargets(command, targetsToBuild, targets);
                }
                else
                {
                    System.Console.WriteLine("usage: bounce build|clean target-name");
                    PrintAvailableTargets(targets);
                    PrintAvailableParameters(parameters);
                    Environment.Exit(1);
                }
            } catch (BounceException ce) {
                ce.Explain(System.Console.Error);
                Environment.Exit(1);
            }
        }
        public void RequiredShouldThrowExceptionIfNoValueGiven()
        {
            var parms = new CommandLineParameters();
            var version = parms.Required<string>("version");

            Assert.That(() => parms.ParseCommandLineArguments(new List<ParsedCommandLineParameter>()), Throws.InstanceOf(typeof(CommandLineParametersException)));
        }
Пример #10
0
        public void TestBadNumericArgument()
        {
            var argv       = new[] { "--boolean", "--string", "astring", "--numeric", "nineteen eighty-four" };
            var parameters = new CommandLineParameters(argv, _typeOptions);

            Assert.IsFalse(parameters.IsValid);
        }
Пример #11
0
        public void VersionRange_must_be_a_valid_version_range_if_parameter_is_set(string version)
        {
            // ARRANGE
            using var repositoryDirectory = new TemporaryDirectory();

            var parameters = new CommandLineParameters()
            {
                RepositoryPath = repositoryDirectory,
                VersionRange   = version
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.False(result.IsValid);
            var error = Assert.Single(result.Errors);

            Assert.Equal(nameof(CommandLineParameters.VersionRange), error.PropertyName);

            // error message should contain commandline parameter name (specified using the Option attribute) instead of the property name
            Assert.Contains("'versionRange'", error.ErrorMessage);
        }
Пример #12
0
        public void RequiredValueShouldThrowIfNotParsedYet()
        {
            var parms = new CommandLineParameters();
            var version = parms.Required<string>("version");

            Assert.That(() => version.Value, Throws.Exception);
        }
Пример #13
0
        public void ConfigurationFilePath_must_exists_if_parameter_is_set()
        {
            // ARRANGE
            using var repositoryDirectory = new TemporaryDirectory();
            var configurationFilePath = Path.Combine(repositoryDirectory, "config.json");

            var parameters = new CommandLineParameters()
            {
                RepositoryPath        = repositoryDirectory,
                ConfigurationFilePath = configurationFilePath
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.False(result.IsValid);
            var error = Assert.Single(result.Errors);

            Assert.Equal(nameof(CommandLineParameters.ConfigurationFilePath), error.PropertyName);

            // error message should contain commandline parameter name (specified using the Option attribute) instead of the property name
            Assert.Contains("'configurationFilePath'", error.ErrorMessage);
        }
Пример #14
0
        public void RepositoryPath_must_exists()
        {
            // ARRANGE
            using var temporaryDirectory = new TemporaryDirectory();
            var nonExistingDirectory = Path.Combine(temporaryDirectory, "someDir");

            var parameters = new CommandLineParameters()
            {
                RepositoryPath = nonExistingDirectory
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.False(result.IsValid);
            var error = Assert.Single(result.Errors);

            Assert.Equal(nameof(CommandLineParameters.RepositoryPath), error.PropertyName);

            // error message should contain commandline parameter name (specified using the Option attribute) instead of the property name
            Assert.Contains("'repository'", error.ErrorMessage);
        }
Пример #15
0
        public void ReportResult(List <CommandLineParameters.OptionInfo> options, CommandLineParameters parameters, bool expectedValidity, string message, bool showParameters)
        {
            Expect(parameters.IsValid == expectedValidity, "FAILED: " + message);

            if (showParameters)
            {
                foreach (CommandLineParameters.OptionInfo option in options)
                {
                    if (option.Type == typeof(bool))
                    {
                        Console.WriteLine(option.Name + ": {0}", (bool)parameters[option.Name]);
                    }
                    if (option.Type == typeof(string))
                    {
                        Console.WriteLine(option.Name + ": {0}", (string)parameters[option.Name]);
                    }
                    if (option.Type == typeof(int))
                    {
                        Console.WriteLine(option.Name + ": {0}", (int)parameters[option.Name]);
                    }
                }
            }
            Console.Write("PASSED ");
            Console.WriteLine(message);
            Console.WriteLine();
        }
Пример #16
0
        public void DefaultValueShouldReturnIfNotParsed()
        {
            var parms = new CommandLineParameters();
            var version = parms.Default("version", "0.2");

            Assert.That(version.Value, Is.EqualTo("0.2"));
        }
        public void TestQuietValueIsParsed()
        {
            var options = new CommandLineParameters();
            var args = new[] {"-q"};
            Parser.Default.ParseArguments(args, options);

            Assert.IsTrue(options.Quiet);
        }
        public void TestSingleRunValueIsParsed()
        {
            var options = new CommandLineParameters();
            var args = new[] { "-s" };
            Parser.Default.ParseArguments(args, options);

            Assert.IsTrue(options.SingleRun);
        }
Пример #19
0
        public void ShouldThrowIfParameterGivenButNoneRegistered()
        {
            var parms = new CommandLineParameters();

            var parsedCommandLineParameters = new List<ParsedCommandLineParameter>();
            parsedCommandLineParameters.Add(new ParsedCommandLineParameter {Name = "provided", Value = "value"});
            Assert.That(() => parms.ParseCommandLineArguments(parsedCommandLineParameters), Throws.InstanceOf(typeof(CommandLineParametersException)));
        }
Пример #20
0
 /* *******************************************************************
 *  Constructors
 * *******************************************************************/
 #region protected BaseOperation(CommandLineParameters parameters)
 /// <summary>
 /// Initializes a new instance of the <b>BaseOperation</b> class.
 /// </summary>
 /// <param name="parameters"></param>
 /// <exception cref="ArgumentNullException">If <paramref name="parameters"/> is null.</exception>
 protected BaseOperation(CommandLineParameters parameters)
 {
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     _parameters = parameters;
 }
Пример #21
0
        public void MakeParameters_InvalidValues_Test(string startPath, string action, string file)
        {
            string[] args = { startPath, action, file };

            var result = CommandLineParameters.MakeParameters(args);

            Assert.IsNull(result);
        }
Пример #22
0
        protected override void OnStart(string[] arguments)
        {
            var parser = new CommandLineParser(new CommandLineParserSettings());
            var commandLineParameters = new CommandLineParameters();

            parser.ParseArguments(arguments, commandLineParameters);

            bottomShelfHost.Start(commandLineParameters);
        }
Пример #23
0
        public void TestQuietValueIsParsed()
        {
            var options = new CommandLineParameters();
            var args    = new[] { "-q" };

            Parser.Default.ParseArguments(args, options);

            Assert.IsTrue(options.Quiet);
        }
Пример #24
0
        public void TestSingleRunValueIsParsed()
        {
            var options = new CommandLineParameters();
            var args    = new[] { "-s" };

            Parser.Default.ParseArguments(args, options);

            Assert.IsTrue(options.SingleRun);
        }
Пример #25
0
        static void InitializeContainer(CommandLineParameters parameters)
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <StrPathCalculator>().As <IPathCalculator>().SingleInstance();

            builder.RegisterType <ConsolePrinter>().As <IPrinter>().SingleInstance();

            builder.Register(
                ctx => parameters.IsConsole() ? (IResultWriter)(new ConsoleWriter()) : (new FileWriter(parameters.ResultFile, ctx.Resolve <IPrinter>()))
                ).SingleInstance();

            builder.Register(
                ctx =>
            {
                IFileHandler result        = null;
                IResultWriter writer       = ctx.Resolve <IResultWriter>();
                IPathCalculator calculator = ctx.Resolve <IPathCalculator>();
                IPrinter printer           = ctx.Resolve <IPrinter>();
                switch (parameters.GetAction())
                {
                case Core.Action.All:
                    result = new SimpleFileHandler(printer);
                    break;

                case Core.Action.Cs:
                    result = new CsFileHandler(printer);
                    break;

                case Core.Action.ReversedOne:
                    result = new ReverseOneFileHandler(printer);
                    break;

                case Core.Action.ReversedTwo:
                    result = new ReverseTwoFileHandler(printer);
                    break;

                default:
                    throw new Exception($"Invalid action: [{parameters.ActionStr}]");
                }

                return(result);
            }
                ).InstancePerLifetimeScope();

            builder.Register <IDirectoryHandler>(
                ctx => new DirectoryHandler(parameters.StartDirectory,
                                            ctx.Resolve <IFileHandler>(),
                                            ctx.Resolve <IResultWriter>(),
                                            ctx.Resolve <IPathCalculator>(),
                                            ctx.Resolve <IPrinter>())
                ).InstancePerLifetimeScope();

            builder.RegisterType <Scanner>().As <IScanner>().InstancePerLifetimeScope();

            _container = builder.Build();
        }
Пример #26
0
        public void ParserGeneratesCommand()
        {
            var parameters = CommandLineParameters.Parse(KInitParameters);

            var command = parameters.CreateCommandExecutor(InputControl.Default());

            Assert.IsNotNull(command);
            Assert.IsInstanceOfType(command, typeof(KerberosInitCommand));
        }
Пример #27
0
        public void GetAction_ConvertFromString_Test(string action, Action result)
        {
            string[] args = { $"-s {_tempPath}", $"-a {action}" };

            var options = CommandLineParameters.MakeParameters(args);

            Assert.IsNotNull(options);
            Assert.IsTrue(options.GetAction() == result);
        }
Пример #28
0
        public void TestCommandlineParametersArguments()
        {
            var argv       = new[] { "--boolean", "--string", "astring", "--numeric", "1984", "42", "foo" };
            var parameters = new CommandLineParameters(argv, _typeOptions);

            Assert.AreEqual(2, parameters.Arguments.Count);
            Assert.Contains("42", parameters.Arguments);
            Assert.Contains("foo", parameters.Arguments);
        }
        public static void Start(CommandLineParameters opts, IListener listener = null)
        {
            if (listener != null)
            {
                AppListener = listener;
            }

            RunServer(opts);
        }
Пример #30
0
        public void IsConsole_Fail_Test(string console)
        {
            string[] args = { $"-s {_tempPath}", $"-a {console}" };

            var options = CommandLineParameters.MakeParameters(args);

            Assert.IsNotNull(options);
            Assert.IsFalse(options.IsConsole());
        }
Пример #31
0
        public void IsValid_Action_Fail_Test(string action)
        {
            string[] args = { $"-s {_tempPath}", $"-a {action}" };

            var options = CommandLineParameters.MakeParameters(args);

            Assert.IsNotNull(options);
            Assert.IsFalse(options.IsValid());
        }
Пример #32
0
        public void RequiredShouldReturnValueWhenGiven()
        {
            var parms = new CommandLineParameters();
            var version = parms.Required<string>("version");

            parms.ParseCommandLineArguments(new List<ParsedCommandLineParameter> {new ParsedCommandLineParameter {Name = "version", Value = "0.2"}});

            Assert.That(version.Value, Is.EqualTo("0.2"));
        }
Пример #33
0
        private static CommandLineParameters GetCommandline(string[] args)
        {
            CommandLineParameters commandLineParameters = CommandLineParameters.FromFile(args);

            if (commandLineParameters == null)
            {
                commandLineParameters = CommandLineParameters.FromArguments(args);
            }

            // Checks
            if (commandLineParameters.Result.HasErrors)
            {
                ErrorHandler.Log($"Error in parameters: {commandLineParameters.Result.ErrorText}");
            }

            commandLineParameters.FileForVersion = Path.GetFullPath(commandLineParameters.FileForVersion);
            if (!File.Exists(commandLineParameters.FileForVersion))
            {
                ErrorHandler.Log($"File not exists: {commandLineParameters.FileForVersion}");
            }

            var extension = Path.GetExtension(commandLineParameters.FileForVersion)?.ToLower();

            if (extension != ".dll" &&
                extension != ".exe")
            {
                ErrorHandler.Log($"File type not supported: {extension}");
            }

            if (commandLineParameters.ReleaseAttachments != null)
            {
                for (var index = 0; index < commandLineParameters.ReleaseAttachments.Count; index++)
                {
                    commandLineParameters.ReleaseAttachments[index] =
                        Path.GetFullPath(commandLineParameters.ReleaseAttachments[index]);
                    var attachment = commandLineParameters.ReleaseAttachments[index];
                    if (!File.Exists(attachment))
                    {
                        ErrorHandler.Log($"Attachment file not found: {attachment}");
                    }
                }
            }

            LogParameter(nameof(commandLineParameters.GitHubRepo), commandLineParameters.GitHubRepo);
            LogParameter(nameof(commandLineParameters.GitHubToken), commandLineParameters.GitHubToken);
            LogParameter(nameof(commandLineParameters.FileForVersion), commandLineParameters.FileForVersion);
            LogParameter(nameof(commandLineParameters.IsChangelogFileCreationEnabled),
                         commandLineParameters.IsChangelogFileCreationEnabled);
            LogParameter(nameof(commandLineParameters.IsPreRelease), commandLineParameters.IsPreRelease);
            LogParameter(nameof(commandLineParameters.IsUpdateOnly), commandLineParameters.IsUpdateOnly);
            LogParameter(nameof(commandLineParameters.IssueFilterLabel), commandLineParameters.IssueFilterLabel);
            LogParameter(nameof(commandLineParameters.IssueLabels), commandLineParameters.IssueLabels);
            LogParameter(nameof(commandLineParameters.ReleaseAttachments), commandLineParameters.ReleaseAttachments);

            return(commandLineParameters);
        }
Пример #34
0
        public void StringAsInteger()
        {
            var parameters = new CommandLineParameters(_typeStrings, _typeOptions);

            Expect(parameters.IsValid);
#pragma warning disable 168
            int test = parameters["string"];
#pragma warning restore 168
            Expect(false, "FAILED type test: string as integer didn't throw exception.");
        }
Пример #35
0
        public void MakeParameters_DefaultValues_Test(string startPath)
        {
            string[] args = { startPath };

            var result = CommandLineParameters.MakeParameters(args);

            Assert.IsNotNull(result);
            Assert.AreEqual("all", result.ActionStr);
            Assert.AreEqual("results.txt", result.ResultFile);
        }
Пример #36
0
        public void BoolAsString()
        {
            var parameters = new CommandLineParameters(_typeStrings, _typeOptions);

            Expect(parameters.IsValid);
#pragma warning disable 168
            string test = parameters["boolean"];
#pragma warning restore 168
            Expect(false, "FAILED type test: boolean as string didn't throw exception.");
        }
Пример #37
0
 public MainService(
     IHostApplicationLifetime appLifetime,
     IOptions <CommandLineParameters> cmdParams,
     IOptions <AppSetting> appSettings
     )
 {
     this.appLifetime = appLifetime;
     this.cmdParams   = cmdParams.Value;
     this.appSettings = appSettings.Value;
 }
Пример #38
0
        public void IntegerAsBool()
        {
            var parameters = new CommandLineParameters(_typeStrings, _typeOptions);

            Expect(parameters.IsValid);
#pragma warning disable 168
            bool test = parameters["numeric"];
#pragma warning restore 168
            Expect(false, "FAILED type test: integer as boolean didn't throw exception.");
        }
        private static void RunServer(CommandLineParameters opts)
        {
            CheckFirewall(opts.Port);
            Key = CryptoService.Encrypt(opts.Password);
            KeyMaster.Action.Application = opts.Application;
            string baseAddress = "http://" + "*" + ":" + opts.Port + "/";

            host = CreateHostBuilder(baseAddress).Build();
            host.Run();
        }
Пример #40
0
        public void MakeParameters_ValidValues_Test(string startPath, string action, string file)
        {
            string[] args = { startPath, action, file };

            var result = CommandLineParameters.MakeParameters(args);

            Assert.IsNotNull(result);
            StringAssert.EndsWith(startPath, result.StartDirectory);
            StringAssert.EndsWith(action, result.ActionStr);
            StringAssert.EndsWith(file, result.ResultFile);
        }
Пример #41
0
        public void ShouldThrowIfParameterGivenButNoneRegistered()
        {
            var parms = new CommandLineParameters();

            var parsedCommandLineParameters = new List <ParsedCommandLineParameter>();

            parsedCommandLineParameters.Add(new ParsedCommandLineParameter {
                Name = "provided", Value = "value"
            });
            Assert.That(() => parms.ParseCommandLineArguments(parsedCommandLineParameters), Throws.InstanceOf(typeof(CommandLineParametersException)));
        }
Пример #42
0
        public void RequiredShouldThrowExceptionIfNoValueGiven()
        {
            var parms = new CommandLineParameters();

            var param1 = (IParameter) parms.Required<string>("provided");
            var param2 = (IParameter) parms.Required<int>("notprovided");

            var parsedCommandLineParameters = new List<ParsedCommandLineParameter>();
            parsedCommandLineParameters.Add(new ParsedCommandLineParameter {Name = "provided", Value = "value"});
            parms.ParseCommandLineArguments(parsedCommandLineParameters);

            Assert.That(() => parms.EnsureAllRequiredParametersHaveValues(new [] {param1, param2}), Throws.InstanceOf(typeof(CommandLineParametersException)));
        }
Пример #43
0
        public void AbleToUseBounceFromOutside()
        {
            // arrange
            var bounce = new BounceFactory().GetBounce();
            var targetsRetriever = new TargetsRetriever();
            var parameters = new CommandLineParameters();

            var targets = targetsRetriever.GetTargetsFromObject(GetTargets(parameters)).ToTargets();
            var command = BounceCommandFactory.GetCommandByName("build");
            var builder = new TargetsBuilder();

            // act
            builder.BuildTargets(bounce, targets, command);

            // assert
            Assert.That(Directory.Exists(GitCheckoutDirectory), Is.True);
        }
Пример #44
0
        public void Run(string[] args, MethodInfo getTargetsMethod)
        {
            TargetsPath = new Uri(getTargetsMethod.Module.Assembly.CodeBase).LocalPath;

            var parameters = new CommandLineParameters();

            try {
                IDictionary<string, IObsoleteTask> targets = GetTargetsFromAssembly(getTargetsMethod, parameters);

                ParsedCommandLineParameters parsedParameters = ParseCommandLineArguments(args);

                string[] buildArguments = parsedParameters.RemainingArguments;

                CommandAndTargets commandAndTargets = CommandAndTargetParser.ParseCommandAndTargetNames(buildArguments, targets);

                if (commandAndTargets.Targets.Count() >= 1) {
                    var bounce = new Bounce();

                    InterpretParameters(parameters, parsedParameters, bounce);

                    try
                    {
                        EnsureAllRequiredParametersAreSet(parameters, commandAndTargets.Targets);

                        BuildTargets(bounce, commandAndTargets);
                    }
                    catch (BounceException ce)
                    {
                        ce.Explain(bounce.LogOptions.StdErr);
                        Environment.Exit(1);
                    }
                }
                else
                {
                    System.Console.WriteLine("usage: bounce build|clean target-name");
                    PrintAvailableTargets(targets);
                    Environment.Exit(1);
                }
            } catch (BounceException ce) {
                ce.Explain(System.Console.Error);
                Environment.Exit(1);
            }
        }
Пример #45
0
        public static void Run(CommandLineParameters options)
        {
            var installUtilArguments = new List<string>();
            installUtilArguments.Add(Assembly.GetExecutingAssembly().Location);
            installUtilArguments.Add("/LogToConsole=true");
            DelayedAutoStart = options.DelayedAutoStart;

            ServiceAccount serviceAccount;
            Enum.TryParse(options.ServiceAccount, true, out serviceAccount);
            Account = serviceAccount;

            ServiceStartMode startType;
            Enum.TryParse(options.StartType, true, out startType);
            StartType = startType;

            if(options.UninstallWindowsService)
                installUtilArguments.Add("/u");

            ManagedInstallerClass.InstallHelper(installUtilArguments.ToArray());
        }
Пример #46
0
        private Dictionary<string, ITask> GetTargetsFromAssembly(MethodInfo getTargetsMethod, CommandLineParameters parameters)
        {
            object targetsObject = GetTargetsObjectFromAssembly(getTargetsMethod, parameters);

            Dictionary<string, ITask> targets = new Dictionary<string, ITask>();

            foreach (PropertyInfo property in targetsObject.GetType().GetProperties()) {
                targets[property.Name] = (ITask) property.GetValue(targetsObject, new object[0]);
            }

            return targets;
        }
Пример #47
0
 private IDictionary<string, IObsoleteTask> GetTargetsFromAssembly(MethodInfo getTargetsMethod, CommandLineParameters parameters)
 {
     return TargetsRetriever.GetTargetsFromAssembly(getTargetsMethod, parameters);
 }
Пример #48
0
 private void EnsureAllRequiredParametersAreSet(CommandLineParameters parameters, IEnumerable<Target> targetsToBuild)
 {
     var tasks = targetsToBuild.Select(t => t.Task);
     foreach (IObsoleteTask task in tasks) {
         IEnumerable<IParameter> parametersForTask = ParameterFinder.FindParametersInTask(task);
         parameters.EnsureAllRequiredParametersHaveValues(parametersForTask);
     }
 }
Пример #49
0
        /// <summary>
        /// Generate usage text for the script with given ID and descriptions
        /// </summary>
        /// <param name="context">Script context</param>
        /// <param name="description">Script description</param>
        /// <param name="id">Script ID</param>
        /// <param name="width">Console width</param>
        /// <param name="items">Command line parameters</param>
        /// <returns></returns>
        public string GetUsage(ScriptContext context, string description, string id, int width, CommandLineParameters items)
        {
            width = CorrectWidth(width);

            StringWriter sw = new StringWriter();

            // Write description
            if (!string.IsNullOrEmpty(description))
            {
                Utils.Wrap(sw, description, width, string.Empty);
                sw.WriteLine();
            }

            if ((Options & UsageOptions.UsageLine) != 0)
            {
                string prefix = LinePrefix + id;

                StringBuilder line = new StringBuilder(prefix);
                bool optional = false;
                foreach (CommandLineParameter p in items)
                {
                    string text = p.GetTransformedValue(context);
                    string vardescr = p.GetDescription(context);
                    if (p.Required)
                    {
                        if (!string.IsNullOrEmpty(p.Switch))
                            line.Append(" " + items.GetSwitchPrefixesArray()[0] + p.Switch);
                        if (p.Count != CommandLineValueCount.None)
                            line.Append(" " + p.GetDescription(context));
                    }
                    else if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(p.Switch))
                        optional = true;
                    else if (p.Count != CommandLineValueCount.None && string.IsNullOrEmpty(p.Switch) && !string.IsNullOrEmpty(vardescr))
                        line.Append(" [" + vardescr + "]");
                }

                if (optional && LineSuffix == null)
                    line.Append(" [parameters]");
                line.Append(LineSuffix);
                Utils.Wrap(sw, line.ToString(), width, new string(' ', prefix.Length + 1));
            }

            foreach (CommandLineParameter p in items)
            {
                string text = p.GetTransformedValue(context);
                if (!string.IsNullOrEmpty(text) &&
                    ((p.Switch ?? string.Empty).Trim().Length != 0 ||
                     (!string.IsNullOrEmpty(p.Var) && !string.IsNullOrEmpty(p.Value))))
                {
                    if ((Options & UsageOptions.UsageLine) != 0)
                        sw.WriteLine();
                    break;
                }
            }
            sw.Write(getArgsUsage(context, width, items));
            return sw.ToString();
        }
Пример #50
0
        /// Get script usage, not exceeding the given width (-1 = autodetect width)
        public string GetAutoUsage(Script s, int width)
        {
            string id = s.Id;
            if (string.IsNullOrEmpty(id))
                id=Path.GetFileNameWithoutExtension(s.Location).ToUpperInvariant();

            StringWriter sw = new StringWriter();
            string desc = null;
            if ((s.Usage.Options & UsageOptions.UseVersionInfo)!=0)
                desc=s.VersionInfo.GenerateInfo(this, true);

            CommandLineParameters c=new CommandLineParameters(s.Parameters,s.SwitchPrefixes,s.UnknownSwitches);
            sw.Write(s.Usage.GetUsage(this,desc, id, width, c));
            return sw.ToString();
        }
Пример #51
0
        static void ShowUsage(CommandLineParameters clps)
        {
            Console.WriteLine("Usage :\n\n\tConsoleRunner [wildcard or filename for story file][...] [parameters]");
              Console.WriteLine("\nWhere parameters can be one of the following :" );
              foreach(var clp in clps)
              {
                  var typedesc = "  ";
                  if (clp.Type != ParameterType.Flag)
                      typedesc += "XXXX";
                  if (clp.Type == ParameterType.Multiple)
                      typedesc+="[, ...]*";

                  Console.WriteLine("\n\t -"+string.Join(",-",clp.Names) + typedesc);
                  Console.WriteLine("\t\t" + clp.Description);

              }
        }
Пример #52
0
 /// <summary>
 /// Execute script against the current Context.
 /// 
 /// This method is not intended to be called directly.
 /// </summary>
 /// <returns>Script return value</returns>
 public virtual object ExecuteScript()
 {
     //
     CommandLineParameters c = new CommandLineParameters(Parameters, SwitchPrefixes, UnknownSwitches);
     c.ApplyDefaultValues(Context);
     c.CheckRequiredValues(Context);
     return ReturnValue.Unwrap(base.Execute());
 }
Пример #53
0
        private static CommandLineParameters getXsParams()
        {
            CommandLineParameters args = new CommandLineParameters(
                new[]
                    {
                        new CommandLineParameter {Value = "Syntax: XSharper [<script>] [//engine parameters] [<script parameters>]"},
                        new CommandLineParameter {},
                        new CommandLineParameter {Value = "Parameters may be specified as /name value, or as /name=value, or as /name:value. Parameter names are case insensitive."},
                        new CommandLineParameter {},

                        new CommandLineParameter(xs.script, null, CommandLineValueCount.Single, null, null) {Description = "script.xsh", Value = "XML file to execute. If . (dot) is specified, <xsharper> section from the configuration file is loaded."},
                        new CommandLineParameter(xs.scriptargs, null, CommandLineValueCount.Multiple, null, null) {Description = "<script parameters>"},

                        new CommandLineParameter {},
                        new CommandLineParameter {Value = "   --- basic parameters ---"},
                        new CommandLineParameter(xs.config, CommandLineValueCount.None, null, "true") {Value = "Use an alternative configuration file", Description = "app.config"},
                        new CommandLineParameter(xs.quiet, CommandLineValueCount.None, null, "true") {Value = "Don't display informational messages"},
                        new CommandLineParameter(xs.debug, CommandLineValueCount.None, "0", "true") {Value = "Turn on additional debug output (visible with dbgview)"},
                        new CommandLineParameter(xs.debugc, CommandLineValueCount.None, "0", "true") {Value = "Turn on additional debug output (written to console)"},
                        new CommandLineParameter(xs.verbose, CommandLineValueCount.None, "0", "true") {Value = "Turn on script engine debug output"},
                        new CommandLineParameter(xs.trace, CommandLineValueCount.None, null, "true") {Value = "Trace script progress"},
                        new CommandLineParameter(xs.wait, CommandLineValueCount.None, null, "true") {Value = "Display execution time and wait for user input before terminating"},
                        new CommandLineParameter(xs.nocolors, CommandLineValueCount.None, null, "true") {Value = "Output to console in the same color"},
                        new CommandLineParameter(xs.path, CommandLineValueCount.Single, null, "") {Value = "; separated list of directories to search for scripts", Description = "directories", Default = Environment.GetEnvironmentVariable("XSH_PATH")},
                        new CommandLineParameter(xs.@ref, CommandLineValueCount.Single, null, "") {Value = "; separated list of assemblies or assembly filenames to load", Description = "references", Default = Environment.GetEnvironmentVariable("XSH_REF")},
                        new CommandLineParameter(xs.log, CommandLineValueCount.Single, null, "xsharper.log") {Value = "Copy all output to the specified file", Description = "log.txt"},
                        new CommandLineParameter(xs.requireAdmin, CommandLineValueCount.None, null, "Admin") {Value = "Force process elevation to obtain admin privileges (RunAs)"},
                        new CommandLineParameter(xs.validate, CommandLineValueCount.None, null, "true") {Value = "Validate script signature"},
                        new CommandLineParameter(xs.utf8, CommandLineValueCount.None, "false", "true") {Value = "Force UTF8 console output. ANSI is used if not specified."},
                        new CommandLineParameter(xs.last, CommandLineValueCount.None, null, "true") {Last = true, Value = "Stop looking for //* parameters after this"},

                        new CommandLineParameter {},
                        new CommandLineParameter {Value = "   --- code & schema generation ---"},
                        new CommandLineParameter(xs.save, CommandLineValueCount.Single, null, "xsharper_save.xsh") {Value = "Save script to the specified xml file", Description = "x.xsh"},
                        new CommandLineParameter(xs.gensample, CommandLineValueCount.Single, null, "sample.xsh") {Value = "Generate a sample script file x.xsh", Description = "x.xsh"},
                        new CommandLineParameter(xs.genconfig, CommandLineValueCount.Single, null, "app.config") {Value = "Generate a sample config file", Description = "app.config"},
                        new CommandLineParameter(xs.genxsd, CommandLineValueCount.Single, null, "*") {Value = "Generate and save XML schema", Description = "schema.xsd"},
                        new CommandLineParameter(xs.gencs, CommandLineValueCount.Single, null, "*") {Value = "Generate C# source code into file x.cs", Description = "x.cs"},
                        new CommandLineParameter(xs.forcenet20, CommandLineValueCount.None, null, "true") {Value = "Generate C# source code using .NET 2.0 syntax"},
                        new CommandLineParameter(xs.@namespace, CommandLineValueCount.Single, null, null) {Value = "Namespace for generated C# code (GUID if not specified)", Description = "namespace"},
                        new CommandLineParameter(xs.@class, CommandLineValueCount.Single, null, null) {Value = "Class name of the generated C# code"},
                        new CommandLineParameter(xs.main, CommandLineValueCount.None, null, "true") {Value = "Create Program.Main entry point"},

                        new CommandLineParameter {},
                        new CommandLineParameter {Value = "   --- executable generation ---"},
                        new CommandLineParameter(xs.genexe, CommandLineValueCount.Single, null, "*") {Value = "Generate standalone console executable", Description = "x.exe"},
                        new CommandLineParameter(xs.genwinexe, CommandLineValueCount.Single, null, "*") {Value = "Generate standalone Windows executable", Description = "x.exe"},
                        new CommandLineParameter(xs.genlibrary, CommandLineValueCount.Single, null, "*") {Value = "Generate standalone assembly", Description = "x.dll"},
                        new CommandLineParameter(xs.icon, CommandLineValueCount.Single) {Value = "Icon file for the produced executable (requires .NET 3.5 compiler)", Description = "x.ico"},
                        new CommandLineParameter(xs.compilerOptions, CommandLineValueCount.Single, null, null) {Value = "Extra C# compiler options", Description = "options"},
                        new CommandLineParameter(xs.noSrc, CommandLineValueCount.None, null, "true") {Value = "Do not include C# source code into the executable"},
                        new CommandLineParameter(xs.codeout, CommandLineValueCount.Single, null, null) {Value = "Save temporary .cs files in this directory", Description = "directory"},

                        new CommandLineParameter {},
                        new CommandLineParameter {Value = "   --- inline scripts ---"},
                        new CommandLineParameter(xs.execRest, "/", CommandLineValueCount.Multiple, null, "true") {Last = true, Value = "Execute a piece of xml or C# code until the end of the line, replacing ` with \"", Description = "code"},
                        new CommandLineParameter(xs.execRestD, "/#", CommandLineValueCount.Multiple, null, "true") {Synonyms = "/#?", Last = true, Value = "Same as above, but evaluate and dump the result", Description = "code"},
                        new CommandLineParameter(xs.execRestP, "/p", CommandLineValueCount.Multiple, null, "true") {Last = true, Value = "Same as above, but evaluate and print the result", Description = "code"},

                        new CommandLineParameter {},
                        new CommandLineParameter {Value = "   --- built-in scripts (use /" + xs.save.Replace("xs.", "/") + " to save instead of executing) ---"},
                        new CommandLineParameter(xs.download, CommandLineValueCount.Multiple, null, null) {Unspecified = "/?", Description = "uri", Value = "Download from url, and save to file"},
                        new CommandLineParameter(xs.zip, CommandLineValueCount.Multiple, null, null) {Unspecified = "/?", Value = "Archive directory to a .zip file", Description = "archive.zip"},
                        new CommandLineParameter(xs.unzip, CommandLineValueCount.Multiple, null, null) {Unspecified = "/?", Value = "Extract a .zip file to directory", Description = "archive.zip",},
                        new CommandLineParameter(xs.version, CommandLineValueCount.None, null, "true") {Value = "Display XSharper version"},

                        new CommandLineParameter {},
                        new CommandLineParameter {Value = "   --- utilitites ---"},
                        new CommandLineParameter(xs.upgrade, CommandLineValueCount.None, null, "true") {Value = "Upgrade this executable to the latest XSharper version"},
                        new CommandLineParameter(xs.help, CommandLineValueCount.Single, null, "") {Value = "If action or class name is not specified, display this text. If action is *, display the list of actions. Otherwise display specific action/class help", Description = "action/class"},

                        // These are undocumented test commands
                        new CommandLineParameter(xs.testElevation, CommandLineValueCount.None, null, "true"),
                        new CommandLineParameter(xs.updateStage, CommandLineValueCount.Multiple, null, null)
                    }, "//", false);
            foreach (var a in args)
                if (!string.IsNullOrEmpty(a.Name) && string.IsNullOrEmpty(a.Switch) && a.Name!=xs.script && a.Name!=xs.scriptargs)
                    a.Switch = a.Name.Replace("xs.","");
            return args;
        }
Пример #54
0
 /// <summary>
 /// Initializes a new instance of the <b>ExportQueryOperation</b> class.
 /// </summary>
 /// <param name="parameters"></param>
 public ExportQueryOperation(CommandLineParameters parameters)
     : base(parameters)
 {
 }
Пример #55
0
 public CompilerDriver(CommandLineParameters args)
 {
     Args = args;
 }
Пример #56
0
        public static int Help(ScriptContext context, UsageGenerator usage, CommandLineParameters xsParams)
        {
            context.WriteLine(OutputType.Bold, GetLogo(context));
            context.WriteLine();

            var command = context.GetStr(xs.help, null);
            if (!string.IsNullOrEmpty(command))
            {
                var tt = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
                tt["param"] = typeof (CommandLineParameter);
                tt["versionInfo"] = typeof(VersionInfo);
                tt["usage"] = typeof(UsageGenerator);

                foreach (var s in context.GetKnownTypes())
                {
                    foreach (var at in CustomAttributeHelper.All<XsTypeAttribute>(s))
                        if (!string.IsNullOrEmpty(at.Name))
                            tt[at.Name] = s;
                }

                Type type;
                if (tt.TryGetValue(command,out type))
                {

                    writeCommandHelp(context, type, usage.CorrectWidth(-1));
                    return -2;
                }
                if (command == "*")
                {
                    List<Var> v = new List<Var>();
                    v.Add(new Var("param",getDescr(typeof(CommandLineParameter))));
                    v.Add(new Var("versioninfo", getDescr(typeof(VersionInfo))));
                    v.Add(new Var("usage", getDescr(typeof(UsageGenerator))));

                    foreach (var s in context.GetKnownTypes())
                    {
                        var xst = CustomAttributeHelper.First<XsTypeAttribute>(s);
                        if (xst == null || string.IsNullOrEmpty(xst.Name))
                            continue;
                        v.Add(new Var(xst.Name, getDescr(s)));
                    }
                    v.Sort((a, b) => string.Compare(a.Name, b.Name));
                    v.Insert(0, new Var("Actions:", null));
                    v.Insert(1, new Var("", null));
                    Utils.WrapTwoColumns(context.Out, v, 30, usage.CorrectWidth(-1));
                    return -2;
                }
                if (command.StartsWith(".", StringComparison.Ordinal))
                {
                    bool success = false;
                    foreach (var nn in ((IEvaluationContext)context).GetNonameObjects())
                    {
                        success =writeTypeHelp(context, nn.Type, new StringFilter(command.Substring(1)),usage.CorrectWidth(-1)) || success;
                    }
                    if (!success)
                        context.Error.WriteLine("Cannot find method '" + command + "'. ");
                    return -2;
                }

                Type t = context.FindType(command);
                if (t == null)
                    t = context.FindType("XS." + command);
                if (t != null)
                    writeTypeHelp(context, t, null, usage.CorrectWidth(-1));
                else if (command.Contains("?") || command.Contains("*"))
                {
                    var r = Utils.WildcardToRegex(command, RegexOptions.IgnoreCase);
                    foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
                        foreach (var ttt in a.GetTypes())
                            if (ttt != null && ttt.IsPublic && (r.IsMatch(ttt.Name) || r.IsMatch(Dump.GetFriendlyTypeName(ttt))))
                            {
                                context.WriteLine(Dump.GetFriendlyTypeName(ttt,true));
                            }
                }
                else
                    context.Error.WriteLine("Cannot find command or type '" + command + "'. Use //help * to display the list of commands");
            }
            else
                context.WriteLine(usage.GetUsage(context, null, null, -1, xsParams));
            return -2;
        }
Пример #57
0
        private object GetTargetsObjectFromAssembly(MethodInfo getTargetsMethod, CommandLineParameters parameters)
        {
            ParameterInfo[] methodParameters = getTargetsMethod.GetParameters();
            if (methodParameters.Length == 1) {
                if (methodParameters[0].ParameterType.IsAssignableFrom(typeof(IParameters)))
                {
                    return getTargetsMethod.Invoke(null, new[] { parameters });
                }
            }

            if (methodParameters.Length == 0) {
                return getTargetsMethod.Invoke(null, new object[0]);
            }

            throw new TargetsMethodWrongSignatureException(getTargetsMethod.Name);
        }
Пример #58
0
        static int Main(string[] args)
        {
            var p = new CommandLineParameters();
            p.Define().Name("html").Describe("[Experimental] Output to html unordered lists").Allow(ParameterType.Flag);
            p.Define().Name("fmthdr", "formatheader").Describe("Header to put before starting the children output; example \"<ul>\"");
            p.Define().Name("fmt", "formatter").Describe("Named storyformatter; example \"<li>{Type} {Description} <a href='#' title='{StatusInfo}'>{StatusText}</a></li>\"");
            p.Define().Name("fmtftr", "formatfooter").Describe("Footer to put after ending the children output; example \"</ul>\"");
            p.Define().Name("h", "?", "help").Describe("Show the syntax of the commandline parameters").Allow(ParameterType.Flag);
            p.Define().Name("v", "verbose").Describe("Show verbose output").Allow(ParameterType.Flag);
            p.Define().Name("p", "parseonly").Describe("Only parse the files to look for syntax errors").Allow(ParameterType.Flag);
            p.Define().Name("d", "dsl").Describe("Show the available DSL definitions").Allow(ParameterType.Flag);
            p.Define().Name("c", "context").Describe("The full classname of the default context class to use").Allow(ParameterType.Single);
            p.Define().Name("a", "assembly").Describe("The full name of the assembly the default context class is in").Allow(ParameterType.Single);
            p.Define().Name("db","debugbreak").Describe("Invoke an assert so you can attach a debugger").Allow(ParameterType.Flag);
            //p.Define().Name("s", "syntax").Describe("Filename of a syntax definition file").Allow(ParameterType.Single);
            p.ParseLine(string.Join(" ", args));

            if (p["help"].Count > 0)
            {
                ShowHeader("","");
                ShowUsage(p);
                return 0;
            }

            if (p.Unnamed.Count == 0 && p["d"].Count ==0)
            {
                ShowHeader("","");
                Console.WriteLine("Error : no story files defined or dsl requested; use the switch /h for usage info");
                return -1;
            }

            var fmthdr = p["fmthdr"];
            var fmt = p["fmt"];
            var fmtftr = p["fmtftr"];

            if (p["html"].Count > 0)
            {
                fmthdr.Clear();fmthdr.Add("<ul>");
                fmt.Clear(); fmt.Add("<li>{Type} {Description} <a href='#' title='{StatusInfo}'>{StatusText}</a></li>");
                fmtftr.Clear(); fmtftr.Add("</ul>");
            }

            if (fmthdr.Count == 0) fmthdr.Add("");
            if (fmt.Count == 0) fmt.Add("{Type} {Description} =>{StatusText} {StatusInfo}");
            if (fmtftr.Count == 0) fmtftr.Add("");

            ShowHeader(fmthdr[0],fmtftr[0]);

            var storyextractor = new TextStoryExtractor();
            var dslextractor = new TextDSLExtractor();

            if (p["a"].Count > 0 && p["c"].Count > 0)
            {
                dslextractor.AddDSL("default", p["c"][0], p["a"][0]);
            }

            Console.Write(fmthdr[0]);
            Console.WriteLine("Parsing files");
            foreach (var arg in p.Unnamed)
            {
                Console.Write(fmthdr[0]);
                Console.WriteLine("  Processing file(s) : " + arg);
                foreach (var fn in Directory.GetFiles(Directory.GetCurrentDirectory(), arg))
                {
                    Console.Write(fmthdr[0]);
                    Console.WriteLine("    Parsing file : " + fn);
                    foreach (var line in File.ReadAllLines(fn))
                    {
                        if (string.IsNullOrEmpty(line) || line.Trim() == "") continue;
                        var st = "Skipped";
                        if (dslextractor.ParseLine(line))
                        { st = "Parsed DSL"; }
                        else if (storyextractor.ParseLine(line))
                        { st = "Parsed element"; }
                        if (p["v"].Count > 0)
                        {
                            Console.Write(fmthdr[0]);
                            Console.WriteLine("      "+st+" : " + line);
                            Console.Write(fmtftr[0]);
                        }
                    }
                    Console.Write(fmtftr[0]);
                }
                Console.Write(fmtftr[0]);
            }
            Console.Write(fmtftr[0]);
            if (p["v"].Count + p["p"].Count > 0)
            {
                Console.Write(fmthdr[0]);
                Console.WriteLine("Stories:");
                foreach (var sc in storyextractor.Stories)
                {
                    Console.Write(fmthdr[0]);
                    Console.Write("  "+sc.Story.Description);
                    Console.WriteLine(fmtftr[0]);
                }
                Console.WriteLine(fmtftr[0]);
            }
            if (p["v"].Count + p["d"].Count > 0)
            {
                Console.Write(fmthdr[0]);
                Console.WriteLine("DSLs:");
                foreach (var sc in dslextractor.DSLs.Values)
                {
                    Console.Write(fmthdr[0]);
                    Console.WriteLine("  "+ sc.Name + " [" + sc.ContextType.FullName + "]" );
                    foreach (var r in sc.Elements)
                    {
                        Console.Write(fmthdr[0]);
                        Console.Write("    "+r.Description);
                        Console.WriteLine(fmtftr[0]);
                    }
                    Console.WriteLine(fmtftr[0]);
                }
                Console.WriteLine(fmtftr[0]);
            }

            if (p["db"].Count > 0)
            {
                Console.WriteLine("Please attach the debugger to this process and press return");
                Console.ReadLine();
            }

            if (p["p"].Count == 0)
            {
                var runner = new SpecRunner();

                Console.Write(fmthdr[0]);
                Console.WriteLine("Running Tests");
                foreach (var sc in storyextractor.Stories)
                {
                    Console.WriteLine(fmthdr[0]);
                    var dsl = runner.GetDSL(sc.Story, dslextractor.DSLs);
                    dsl = dsl ?? dslextractor.DSLs["default"];
                    PrettyPrint(runner.RunStory(sc.Story, dsl, sc.ColumnToken), 1, fmthdr[0], fmt[0], fmtftr[0]);
                    Console.WriteLine(fmtftr[0]);
                }
                Console.Write(fmtftr[0]);
            }
            return 0;
        }
Пример #59
0
 /// Parse command line arguments
 public void ParseArguments(IEnumerable<string> args)
 {
     CommandLineParameters c = new CommandLineParameters(Parameters, SwitchPrefixes, UnknownSwitches);
     c.Parse(Context, args, (Usage.Options & UsageOptions.IfHelp) != 0);
 }
Пример #60
0
        private string getArgsUsage(ScriptContext context, int width, CommandLineParameters items)
        {
            List<Var> sb = new List<Var>();

            foreach (CommandLineParameter p in items)
            {
                string text = p.GetTransformedValue(context);
                string vardescr = p.GetDescription(context);

                string name;
                bool emptyName = (p.Switch ?? string.Empty).Trim().Length == 0;
                if (emptyName && string.IsNullOrEmpty(p.Var))
                    name = p.Switch ?? string.Empty;
                else
                {

                    if (string.IsNullOrEmpty(text))
                        continue;
                    if (emptyName)
                        name = " ";
                    else
                    {
                        var pp = items.GetSwitchPrefixesArray();
                        name = "  " + ((pp != null && pp.Length > 0) ? pp[0] : string.Empty) + p.Switch;
                    }
                }

                if (p.Count != CommandLineValueCount.None)
                {

                    if (p.Unspecified == null || emptyName)
                    {
                        if (!string.IsNullOrEmpty(vardescr))
                            name += " " + vardescr;
                    }
                    else
                        name += " [" + vardescr + "]";
                }

                StringBuilder vb = new StringBuilder();
                vb.Append(text);
                if ((Options & UsageOptions.AutoSuffix) != 0)
                {
                    if (p.Required)
                        vb.Append(" (required)");
                    else if (p.Default != null && p.Count != CommandLineValueCount.None)
                    {
                        string def = Utils.To<string>(context.Transform(p.Default, p.Transform));
                        vb.Append(" (default: " + def + ")");
                    }

                }
                Var v = new Var(name, vb.ToString());
                sb.Add(v);
            }

            StringWriter sw = new StringWriter();
            Utils.WrapTwoColumns(sw, sb, 30, width);
            return sw.ToString();
        }