Exemplo n.º 1
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            string            password    = null;
            Argument <string> passwordArg = syntax.DefineOption(
                "password",
                ref password,
                "Password for the Docker Registry the images are pushed to");

            Password = password;

            string            username    = null;
            Argument <string> usernameArg = syntax.DefineOption(
                "username",
                ref username,
                "Username for the Docker Registry the images are pushed to");

            Username = username;

            if (passwordArg.IsSpecified ^ usernameArg.IsSpecified)
            {
                Logger.WriteError($"error: `{usernameArg.Name}` and `{passwordArg.Name}` must both be specified.");
                Environment.Exit(1);
            }
        }
Exemplo n.º 2
0
        public override void ParseCommandLine(ArgumentSyntax syntax)
        {
            base.ParseCommandLine(syntax);

            string gitBranch = "master";

            syntax.DefineOption(
                "git-branch",
                ref gitBranch,
                "GitHub branch to write readmes to (defaults to master)");
            GitBranch = gitBranch;

            string gitOwner = "Microsoft";

            syntax.DefineOption(
                "git-owner",
                ref gitOwner,
                "Owner of the GitHub repo to write readmes to (defaults to Microsoft)");
            GitOwner = gitOwner;

            string gitPath = "teams";

            syntax.DefineOption(
                "git-path",
                ref gitPath,
                "Path within the GitHub repo to write readmes to (defaults to teams)");
            GitPath = gitPath;

            string gitRepo = "mcrdocs";

            syntax.DefineOption(
                "git-repo",
                ref gitRepo,
                "GitHub repo to readmes to (defaults to mcrdocs)");
            GitRepo = gitRepo;

            string gitUsername = null;

            syntax.DefineParameter(
                "git-username",
                ref gitUsername,
                "GitHub username");
            GitUsername = gitUsername;

            string gitEmail = null;

            syntax.DefineParameter(
                "git-email",
                ref gitEmail,
                "GitHub email");
            GitEmail = gitEmail;

            string gitAuthToken = null;

            syntax.DefineParameter(
                "git-auth-token",
                ref gitAuthToken,
                "GitHub authentication token");
            GitAuthToken = gitAuthToken;
        }
Exemplo n.º 3
0
        public void DefineOptions(ArgumentSyntax syntax)
        {
            string architecture = DockerHelper.Architecture.GetDockerName();

            syntax.DefineOption(
                "architecture",
                ref architecture,
                "Architecture of Dockerfiles to operate on - wildcard chars * and ? supported (default is current OS architecture)");
            Architecture = architecture;

            string osType = DockerHelper.OS.GetDockerName();

            syntax.DefineOption(
                "os-type",
                ref osType,
                "OS type (linux/windows) of the Dockerfiles to build - wildcard chars * and ? supported (default is the Docker OS)");
            OsType = osType;

            IReadOnlyList <string> osVersions = Array.Empty <string>();

            syntax.DefineOptionList(
                OsVersionOptionName,
                ref osVersions,
                "OS versions of the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)");
            OsVersions = osVersions;

            IReadOnlyList <string> paths = Array.Empty <string>();

            syntax.DefineOptionList(
                PathOptionName,
                ref paths,
                "Directory paths containing the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)");
            Paths = paths;
        }
Exemplo n.º 4
0
        public override void ParseCommandLine(ArgumentSyntax syntax)
        {
            base.ParseCommandLine(syntax);

            string readmePath = null;

            syntax.DefineOption("readme-path", ref readmePath, "Path of the readme to update (defaults to manifest setting)");
            ReadmePath = readmePath;

            bool skipValidation = false;

            syntax.DefineOption(
                "skip-validation", ref skipValidation, "Skip validating all documented tags are included in the readme");
            SkipValidation = skipValidation;

            bool updateReadme = false;

            syntax.DefineOption("update-readme", ref updateReadme, "Update the readme file");
            UpdateReadme = updateReadme;

            string template = null;

            syntax.DefineOption("template", ref template, "Path to a custom template file");
            Template = template;

            string sourceUrl = null;

            syntax.DefineParameter("source-url", ref sourceUrl, "Base URL of the Dockerfile sources");
            SourceUrl = sourceUrl;
        }
Exemplo n.º 5
0
        public override void ParseCommandLine(ArgumentSyntax syntax)
        {
            base.ParseCommandLine(syntax);

            string password = null;

            syntax.DefineOption(
                "password",
                ref password,
                "Password for the Docker Registry the images are pushed to");
            Password = password;

            string repoOwner = null;

            syntax.DefineOption(
                "repo-owner",
                ref repoOwner,
                "An alternative repo owner which overrides what is specified in the manifest");
            RepoOwner = repoOwner;

            string username = null;

            syntax.DefineOption(
                "username",
                ref username,
                "Username for the Docker Registry the images are pushed to");
            Username = username;
        }
Exemplo n.º 6
0
 protected override void ParseOptions(ArgumentSyntax syntax)
 {
     syntax.DefineOption("u|update-packages", ref _configOptions.UpdatePackages, "Check the NuGet server for more recent versions of each package and update them if applicable.");
     syntax.DefineOption("use-local-packages", ref _configOptions.UseLocalPackages, "Toggles the use of a local NuGet packages folder.");
     syntax.DefineOption("use-global-sources", ref _configOptions.UseGlobalSources, "Toggles the use of the global NuGet sources (default is false).");
     syntax.DefineOption("packages-path", ref _configOptions.PackagesPath, DirectoryPath.FromString, "The packages path to use (only if use-local is true).");
 }
Exemplo n.º 7
0
        public override void ParseCommandLine(ArgumentSyntax syntax)
        {
            base.ParseCommandLine(syntax);

            FilterOptions.ParseCommandLine(syntax);

            int allowedVariance = 5;

            syntax.DefineOption("variance", ref allowedVariance, $"Allowed percent variance in size (default is `{allowedVariance}`");
            AllowedVariance = allowedVariance;

            bool isPullEnabled = false;

            syntax.DefineOption("pull", ref isPullEnabled, "Pull the images vs using local images");
            IsPullEnabled = isPullEnabled;

            bool updateBaseline = false;

            syntax.DefineOption("update", ref updateBaseline, "Update the baseline file (default is false)");
            UpdateBaseline = updateBaseline;

            string baselinePath = null;

            syntax.DefineParameter("baseline", ref baselinePath, "Path to the baseline file");
            BaselinePath = baselinePath;
        }
Exemplo n.º 8
0
 protected override void ParseOptions(ArgumentSyntax syntax)
 {
     syntax.DefineOption("u|update-packages", ref _configOptions.UpdatePackages, "Check the NuGet server for more recent versions of each package and update them if applicable.");
     syntax.DefineOption("use-local-packages", ref _configOptions.UseLocalPackages, "Toggles the use of a local NuGet packages folder.");
     syntax.DefineOption("use-global-sources", ref _configOptions.UseGlobalSources, "Toggles the use of the global NuGet sources (default is false).");
     syntax.DefineOption("packages-path", ref _configOptions.PackagesPath, DirectoryPath.FromString, "The packages path to use (only if use-local is true).");
 }
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            DateTime minimumQueueTime = DateTime.MinValue;

            syntax.DefineOption(MinimumQueueTimeOptionName, ref minimumQueueTime,
                                val => string.IsNullOrEmpty(val) ? minimumQueueTime : DateTime.Parse(val),
                                "Minimum queue time an image must have to be awaited");
            MinimumQueueTime = minimumQueueTime.ToUniversalTime();

            TimeSpan waitTimeout = TimeSpan.FromMinutes(20);

            syntax.DefineOption("timeout", ref waitTimeout,
                                val => string.IsNullOrEmpty(val) ? waitTimeout : TimeSpan.Parse(val),
                                $"Maximum time to wait for image ingestion (default: {waitTimeout})");
            WaitTimeout = waitTimeout;

            TimeSpan requeryDelay = TimeSpan.FromSeconds(10);

            syntax.DefineOption("requery-delay", ref requeryDelay,
                                val => string.IsNullOrEmpty(val) ? requeryDelay : TimeSpan.Parse(val),
                                $"Amount of time to wait before requerying the status of an image (default: {requeryDelay})");
            RequeryDelay = requeryDelay;
        }
Exemplo n.º 10
0
        public override void ParseCommandLine(ArgumentSyntax syntax)
        {
            base.ParseCommandLine(syntax);

            Architecture = DefineArchitectureOption(syntax);

            string path = null;

            syntax.DefineOption("path", ref path, "Path of the directory to build (Default is to build all)");
            Path = path;

            bool isPushEnabled = false;

            syntax.DefineOption("push", ref isPushEnabled, "Push built images to Docker registry");
            IsPushEnabled = isPushEnabled;

            bool isSkipPullingEnabled = false;

            syntax.DefineOption("skip-pulling", ref isSkipPullingEnabled, "Skip explicitly pulling the base images of the Dockerfiles");
            IsSkipPullingEnabled = isSkipPullingEnabled;

            bool isTestRunDisabled = false;

            syntax.DefineOption("skip-test", ref isTestRunDisabled, "Skip running the tests");
            IsTestRunDisabled = isTestRunDisabled;

            IReadOnlyList <string> nameValuePairs = Array.Empty <string>();

            syntax.DefineOptionList("test-var", ref nameValuePairs, "Named variables to substitute into the test commands (name=value)");
            TestVariables = nameValuePairs
                            .Select(pair => pair.Split(new char[] { '=' }, 2))
                            .ToDictionary(split => split[0], split => split[1]);
        }
Exemplo n.º 11
0
        public void DefineOptions
            (ArgumentSyntax syntax)
        {
            string branch = Branch;

            syntax.DefineOption(
                "git-branch",
                ref branch,
                $"GitHub branch to write to (defaults to '{branch}')");
            Branch = branch;

            string owner = Owner;

            syntax.DefineOption(
                "git-owner",
                ref owner,
                $"Owner of the GitHub repo to write to (defaults to '{owner}')");
            Owner = owner;

            string path = Path;

            syntax.DefineOption(
                "git-path",
                ref path,
                $"Path within the GitHub repo to write to (defaults to '{path}')");
            Path = path;

            string repo = Repo;

            syntax.DefineOption(
                "git-repo",
                ref repo,
                $"GitHub repo to write to (defaults to '{repo}')");
            Repo = repo;
        }
Exemplo n.º 12
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            FilterOptions.DefineOptions(syntax);

            bool isPushEnabled = false;

            syntax.DefineOption("push", ref isPushEnabled, "Push built images to Docker registry");
            IsPushEnabled = isPushEnabled;

            bool isRetryEnabled = false;

            syntax.DefineOption("retry", ref isRetryEnabled, "Retry building images upon failure");
            IsRetryEnabled = isRetryEnabled;

            bool isSkipPullingEnabled = false;

            syntax.DefineOption("skip-pulling", ref isSkipPullingEnabled, "Skip explicitly pulling the base images of the Dockerfiles");
            IsSkipPullingEnabled = isSkipPullingEnabled;

            string imageInfoOutputPath = null;

            syntax.DefineOption("image-info-output-path", ref imageInfoOutputPath, "Path to output image info");
            ImageInfoOutputPath = imageInfoOutputPath;

            string sourceRepoUrl = null;

            syntax.DefineOption("source-repo", ref sourceRepoUrl, "Repo URL of the Dockerfile sources");
            SourceRepoUrl = sourceRepoUrl;
        }
Exemplo n.º 13
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            FilterOptions.DefineOptions(syntax);

            MatrixType matrixType = MatrixType.PlatformDependencyGraph;

            syntax.DefineOption(
                "type",
                ref matrixType,
                value => (MatrixType)Enum.Parse(typeof(MatrixType), value, true),
                $"Type of matrix to generate. {EnumHelper.GetHelpTextOptions(matrixType)}");
            MatrixType = matrixType;

            string customBuildLegGrouping = null;

            syntax.DefineOption(
                "customBuildLegGrouping",
                ref customBuildLegGrouping,
                "Name of custom build leg grouping to use.");
            CustomBuildLegGrouping = customBuildLegGrouping;

            int productVersionComponents = 2;

            syntax.DefineOption(
                "productVersionComponents",
                ref productVersionComponents,
                "Number of components of the product version considered to be significant");
            ProductVersionComponents = productVersionComponents;
        }
Exemplo n.º 14
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            string manifest = "manifest.json";

            syntax.DefineOption("manifest", ref manifest, "Path to json file which describes the repo");
            Manifest = manifest;

            string registryOverride = null;

            syntax.DefineOption("registry-override", ref registryOverride, "Alternative registry which overrides the manifest");
            RegistryOverride = registryOverride;

            IReadOnlyList <string> repos = Array.Empty <string>();

            syntax.DefineOptionList("repo", ref repos, "Repos to operate on (Default is all)");
            Repos = repos;

            string repoPrefix = null;

            syntax.DefineOption("repo-prefix", ref repoPrefix, "Prefix to add to the repo names specified in the manifest");
            RepoPrefix = repoPrefix;

            IReadOnlyList <string> variables = Array.Empty <string>();

            syntax.DefineOptionList("var", ref variables, "Named variables to substitute into the manifest (<name>=<value>)");
            Variables = variables
                        .Select(pair => pair.Split(new char[] { '=' }, 2))
                        .ToDictionary(split => split[0], split => split[1]);
        }
Exemplo n.º 15
0
        protected static void DefineManifestFilterOptions(ArgumentSyntax syntax, IManifestFilterOptions filterOptions)
        {
            string architecture = DockerHelper.Architecture.ToString().ToLowerInvariant();

            syntax.DefineOption(
                "architecture",
                ref architecture,
                "Architecture of Dockerfiles to operate on - wildcard chars * and ? supported (default is current OS architecture)");
            filterOptions.Architecture = architecture;

            string osType = DockerHelper.OS.ToString().ToLowerInvariant();

            syntax.DefineOption(
                "os-type",
                ref osType,
                "OS type (linux/windows) of the Dockerfiles to build - wildcard chars * and ? supported (default is the Docker OS)");
            filterOptions.OsType = osType;

            string osVersion = null;

            syntax.DefineOption(
                "os-version",
                ref osVersion,
                "OS version of the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)");
            filterOptions.OsVersion = osVersion;

            IReadOnlyList <string> paths = Array.Empty <string>();

            syntax.DefineOptionList(
                "path",
                ref paths,
                "Directory paths containing the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)");
            filterOptions.Paths = paths;
        }
Exemplo n.º 16
0
        public override void ParseCommandLine(ArgumentSyntax syntax)
        {
            base.ParseCommandLine(syntax);

            string            password    = null;
            Argument <string> passwordArg = syntax.DefineOption(
                "password",
                ref password,
                "Password for the Docker Registry the images are pushed to");

            Password = password;

            string server = null;

            syntax.DefineOption(
                "server",
                ref server,
                "Docker Registry server the images are pushed to (default is Docker Hub)");
            Server = server;

            string            username    = null;
            Argument <string> usernameArg = syntax.DefineOption(
                "username",
                ref username,
                "Username for the Docker Registry the images are pushed to");

            Username = username;

            if (passwordArg.IsSpecified ^ usernameArg.IsSpecified)
            {
                Logger.WriteError($"error: `{usernameArg.Name}` and `{passwordArg.Name}` must both be specified.");
                Environment.Exit(1);
            }
        }
Exemplo n.º 17
0
        public void DefineOptions(ArgumentSyntax syntax)
        {
            string repo = null;

            syntax.DefineOption(
                "azdo-repo",
                ref repo,
                "Azure DevOps repo");
            Repo = repo;

            string branch = "master";

            syntax.DefineOption(
                "azdo-branch",
                ref branch,
                "Azure DevOps branch (default: master)");
            Branch = branch;

            string path = null;

            syntax.DefineOption(
                "azdo-path",
                ref path,
                "Azure DevOps path");
            Path = path;
        }
Exemplo n.º 18
0
        protected override void ParseOptions(ArgumentSyntax syntax)
        {
            syntax.DefineOption("p|port", ref _port, "Start the preview web server on the specified port (default is " + _port + ").");
            syntax.DefineOption("force-ext", ref _forceExtension, "Force the use of extensions in the preview web server (by default, extensionless URLs may be used).");
            syntax.DefineOption("virtual-dir", ref _virtualDirectory, DirectoryPathFromArg, "Serve files in the preview web server under the specified virtual directory.");
            IReadOnlyList <string> contentTypes = null;

            if (syntax.DefineOptionList("content-type", ref contentTypes, "Specifies additional supported content types for the preview server as extension=contenttype.").IsSpecified)
            {
                AddContentTypes(contentTypes, _contentTypes, syntax);
            }
        }
        public static CommonCompilerOptions Parse(ArgumentSyntax syntax)
        {
            IReadOnlyList<string> defines = null;
            string languageVersion = null;
            string platform = null;
            bool? allowUnsafe = null;
            bool? warningsAsErrors = null;
            bool? optimize = null;
            string keyFile = null;
            bool? delaySign = null;
            bool? strongName = null;
            bool? emitEntryPoint = null;

            Func<string, bool?> nullableBoolConverter = v => bool.Parse(v);

            syntax.DefineOptionList(s_definesTemplate.LongName, ref defines, "Preprocessor definitions");

            syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion,
                    "The version of the language used to compile");

            syntax.DefineOption(s_platformTemplate.LongName, ref platform,
                    "The target platform");

            syntax.DefineOption(s_allowUnsafeTemplate.LongName, ref allowUnsafe,
                    nullableBoolConverter, "Allow unsafe code");

            syntax.DefineOption(s_warningsAsErrorsTemplate.LongName, ref warningsAsErrors,
                    nullableBoolConverter, "Turn all warnings into errors");

            syntax.DefineOption(s_optimizeTemplate.LongName, ref optimize,
                    nullableBoolConverter, "Enable compiler optimizations");

            syntax.DefineOption(s_keyFileTemplate.LongName, ref keyFile,
                    "Path to file containing the key to strong-name sign the output assembly");

            syntax.DefineOption(s_delaySignTemplate.LongName, ref delaySign,
                    nullableBoolConverter, "Delay-sign the output assembly");

            syntax.DefineOption(s_ossSignTemplate.LongName, ref strongName,
                    nullableBoolConverter, "OSS sign the output assembly");

            syntax.DefineOption(s_emitEntryPointTemplate.LongName, ref emitEntryPoint,
                    nullableBoolConverter, "Output an executable console program");

            return new CommonCompilerOptions
            {
                Defines = defines,
                LanguageVersion = languageVersion,
                Platform = platform,
                AllowUnsafe = allowUnsafe,
                WarningsAsErrors = warningsAsErrors,
                Optimize = optimize,
                KeyFile = keyFile,
                DelaySign = delaySign,
                UseOssSigning = strongName,
                EmitEntryPoint = emitEntryPoint
            };
        }
Exemplo n.º 20
0
        public virtual void DefineOptions(ArgumentSyntax syntax)
        {
            bool isDryRun = false;

            syntax.DefineOption("dry-run", ref isDryRun, "Dry run of what images get built and order they would get built in");
            IsDryRun = isDryRun;

            bool isVerbose = false;

            syntax.DefineOption("verbose", ref isVerbose, "Show details about the tasks run");
            IsVerbose = isVerbose;
        }
Exemplo n.º 21
0
        public static CommonCompilerOptions Parse(ArgumentSyntax syntax)
        {
            IReadOnlyList <string> defines = null;
            string languageVersion         = null;
            string platform         = null;
            bool?  allowUnsafe      = null;
            bool?  warningsAsErrors = null;
            bool?  optimize         = null;
            string keyFile          = null;
            bool?  delaySign        = null;
            bool?  publicSign       = null;
            bool?  emitEntryPoint   = null;

            Func <string, bool?> nullableBoolConverter = v => bool.Parse(v);

            syntax.DefineOptionList(s_definesTemplate.LongName, ref defines, "Preprocessor definitions");

            syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion,
                                "The version of the language used to compile");

            syntax.DefineOption(s_platformTemplate.LongName, ref platform,
                                "The target platform");

            syntax.DefineOption(s_allowUnsafeTemplate.LongName, ref allowUnsafe,
                                nullableBoolConverter, "Allow unsafe code");

            syntax.DefineOption(s_warningsAsErrorsTemplate.LongName, ref warningsAsErrors,
                                nullableBoolConverter, "Turn all warnings into errors");

            syntax.DefineOption(s_optimizeTemplate.LongName, ref optimize,
                                nullableBoolConverter, "Enable compiler optimizations");

            syntax.DefineOption(s_keyFileTemplate.LongName, ref keyFile,
                                "Path to file containing the key to strong-name sign the output assembly");

            syntax.DefineOption(s_delaySignTemplate.LongName, ref delaySign,
                                nullableBoolConverter, "Delay-sign the output assembly");

            syntax.DefineOption(s_publicSignTemplate.LongName, ref publicSign,
                                nullableBoolConverter, "Public-sign the output assembly");

            syntax.DefineOption(s_emitEntryPointTemplate.LongName, ref emitEntryPoint,
                                nullableBoolConverter, "Output an executable console program");

            return(new CommonCompilerOptions
            {
                Defines = defines,
                LanguageVersion = languageVersion,
                Platform = platform,
                AllowUnsafe = allowUnsafe,
                WarningsAsErrors = warningsAsErrors,
                Optimize = optimize,
                KeyFile = keyFile,
                DelaySign = delaySign,
                PublicSign = publicSign,
                EmitEntryPoint = emitEntryPoint
            });
        }
Exemplo n.º 22
0
        public void Parse(ArgumentSyntax syntax, Preprocessor preprocessor)
        {
            // Global options
            if(GlobalArguments)
            {
                syntax.DefineOption("v|verbose", ref _verbose, "Turns on verbose output showing additional trace message useful for debugging.");
                syntax.DefineOption("attach", ref _attach, "Pause execution at the start of the program until a debugger is attached.");
            }

            // Command options
            ParseOptions(syntax);

            // Directives
            if (SupportedDirectives != null)
            {
                foreach (IDirective directive in preprocessor.Directives
                    .Where(x => SupportedDirectives.Contains(x.Name, StringComparer.OrdinalIgnoreCase)))
                {
                    // Get the option name and help text
                    string optionName = (string.IsNullOrEmpty(directive.ShortName) ? string.Empty : directive.ShortName + "|") + directive.Name;
                    string optionHelp = $"{directive.Description}{(string.IsNullOrEmpty(directive.GetHelpText()) ? string.Empty : " See below for syntax details.")}";

                    // Single or multiple?
                    if (directive.SupportsMultiple)
                    {
                        // Multiple
                        IReadOnlyList<string> directiveValues = null;
                        syntax.DefineOptionList(optionName, ref directiveValues, optionHelp);
                        if (directiveValues != null)
                        {
                            foreach (string directiveValue in directiveValues)
                            {
                                preprocessor.AddValue(new DirectiveValue(directive.Name, directiveValue));
                            }
                        }
                    }
                    else
                    {
                        // Single
                        string directiveValue = null;
                        syntax.DefineOption(optionName, ref directiveValue, optionHelp);
                        if (directiveValue != null)
                        {
                            preprocessor.AddValue(new DirectiveValue(directive.Name, directiveValue));
                        }
                    }
                }
            }

            // Command parameters
            ParseParameters(syntax);
        }
Exemplo n.º 23
0
        public void Parse(ArgumentSyntax syntax, Preprocessor preprocessor)
        {
            // Global options
            if (GlobalArguments)
            {
                syntax.DefineOption("v|verbose", ref _verbose, "Turns on verbose output showing additional trace message useful for debugging.");
                syntax.DefineOption("attach", ref _attach, "Pause execution at the start of the program until a debugger is attached.");
            }

            // Command options
            ParseOptions(syntax);

            // Directives
            if (SupportedDirectives != null)
            {
                foreach (IDirective directive in preprocessor.Directives
                         .Where(x => SupportedDirectives.Contains(x.Name, StringComparer.OrdinalIgnoreCase)))
                {
                    // Get the option name and help text
                    string optionName = (string.IsNullOrEmpty(directive.ShortName) ? string.Empty : directive.ShortName + "|") + directive.Name;
                    string optionHelp = $"{directive.Description}{(string.IsNullOrEmpty(directive.GetHelpText()) ? string.Empty : " See below for syntax details.")}";

                    // Single or multiple?
                    if (directive.SupportsMultiple)
                    {
                        // Multiple
                        IReadOnlyList <string> directiveValues = null;
                        syntax.DefineOptionList(optionName, ref directiveValues, optionHelp);
                        if (directiveValues != null)
                        {
                            foreach (string directiveValue in directiveValues)
                            {
                                preprocessor.AddValue(new DirectiveValue(directive.Name, directiveValue));
                            }
                        }
                    }
                    else
                    {
                        // Single
                        string directiveValue = null;
                        syntax.DefineOption(optionName, ref directiveValue, optionHelp);
                        if (directiveValue != null)
                        {
                            preprocessor.AddValue(new DirectiveValue(directive.Name, directiveValue));
                        }
                    }
                }
            }

            // Command parameters
            ParseParameters(syntax);
        }
Exemplo n.º 24
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            bool allowOptionalTemplates = false;

            syntax.DefineOption("optional-templates", ref allowOptionalTemplates, "Do not require templates");
            AllowOptionalTemplates = allowOptionalTemplates;

            bool validate = false;

            syntax.DefineOption("validate", ref validate, "Validates the generated artifacts and templates are in sync");
            Validate = validate;
        }
Exemplo n.º 25
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            FilterOptions.DefineOptions(syntax);

            int allowedVariance = 5;

            syntax.DefineOption("variance", ref allowedVariance, $"Allowed percent variance in size (default is `{allowedVariance}`");
            AllowedVariance = allowedVariance;

            bool isPullEnabled = false;

            syntax.DefineOption("pull", ref isPullEnabled, "Pull the images vs using local images");
            IsPullEnabled = isPullEnabled;
        }
Exemplo n.º 26
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            CleanAcrImagesAction action = CleanAcrImagesAction.PruneDangling;

            syntax.DefineOption("action", ref action,
                                value => (CleanAcrImagesAction)Enum.Parse(typeof(CleanAcrImagesAction), value, true),
                                $"Type of delete action. {EnumHelper.GetHelpTextOptions(action)}");
            Action = action;

            int age = 30;

            syntax.DefineOption("age", ref age, $"Minimum age (days) of repo or images to be deleted (default: {age})");
            Age = age;
        }
Exemplo n.º 27
0
        public static ArgumentSyntax DefineOption(this ArgumentSyntax syntax, string name, string help)
        {
            string value = null;
            var    opt   = syntax.DefineOption(name, ref value, true, help);

            return(syntax);
        }
 public static ArgumentSyntax DefineServerOption(this ArgumentSyntax syntax)
 {
     Uri value = null;
     var arg = syntax.DefineOption(ServerOptionName, value, s => new Uri(s));
     arg.Help = Strings.HelpServer;
     return syntax;
 }
Exemplo n.º 29
0
 protected override void Define(ArgumentSyntax syntax, Settings settings)
 {
     syntax.DefineOption("i|ignore-known-packages", ref settings.IgnoreKnownPackages, "Ignores (does not add) packages for known themes.");
     if (!syntax.DefineParameter("theme", ref settings.Theme, "The theme to use.").IsSpecified)
     {
         syntax.ReportError("a theme must be specified.");
     }
 }
Exemplo n.º 30
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            FilterOptions.DefineOptions(syntax);

            bool continuousMode = false;

            syntax.DefineOption("continuous", ref continuousMode, "Runs the status check continuously");
            ContinuousMode = continuousMode;

            const int ContinuousModeDelayDefault = 10;
            int       continuousModeDelay        = ContinuousModeDelayDefault;

            syntax.DefineOption("continuous-delay", ref continuousModeDelay,
                                $"Delay before running next status check (default {ContinuousModeDelayDefault} secs)");
            ContinuousModeDelay = TimeSpan.FromSeconds(continuousModeDelay);
        }
Exemplo n.º 31
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            TimeSpan waitTimeout = TimeSpan.FromMinutes(5);

            syntax.DefineOption("timeout", ref waitTimeout,
                                val => String.IsNullOrEmpty(val) ? waitTimeout : TimeSpan.Parse(val),
                                $"Maximum time to wait for doc ingestion (default: {waitTimeout})");
            WaitTimeout = waitTimeout;

            TimeSpan requeryDelay = TimeSpan.FromSeconds(10);

            syntax.DefineOption("requery-delay", ref requeryDelay,
                                val => String.IsNullOrEmpty(val) ? requeryDelay : TimeSpan.Parse(val),
                                $"Amount of time to wait before requerying the status of the commit (default: {requeryDelay})");
            RequeryDelay = requeryDelay;
        }
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            string sourceRepoBranch = null;

            syntax.DefineOption("source-branch", ref sourceRepoBranch, "Repo branch of the Dockerfile sources (default is commit SHA)");
            SourceRepoBranch = sourceRepoBranch;
        }
Exemplo n.º 33
0
        public override void DefineOptions(ArgumentSyntax syntax)
        {
            base.DefineOptions(syntax);

            string imageInfoPath = null;

            syntax.DefineOption("image-info", ref imageInfoPath, "Path to image info file");
            ImageInfoPath = imageInfoPath;
        }
Exemplo n.º 34
0
 private bool DefineSquirrelOption(ArgumentSyntax syntax, string name, CommandEnum command, bool hasVersion)
 {
     Argument<string> option = syntax.DefineOption(name, ref SquirrelVersion, hasVersion, string.Empty);
     option.IsHidden = true;
     if (option.IsSpecified)
     {
         Command = command;
         return true;
     }
     return false;
 }
Exemplo n.º 35
0
 protected override void ParseOptions(ArgumentSyntax syntax)
 {
     syntax.DefineOption("p|port", ref _port, "Start the preview web server on the specified port (default is " + _port + ").");
     syntax.DefineOption("force-ext", ref _forceExtension, "Force the use of extensions in the preview web server (by default, extensionless URLs may be used).");
 }
        public static CommonCompilerOptions Parse(ArgumentSyntax syntax)
        {
            IReadOnlyList<string> defines = null;
            IReadOnlyList<string> suppressWarnings = null;
            string languageVersion = null;
            string platform = null;
            string debugType = null;
            bool? allowUnsafe = null;
            bool? warningsAsErrors = null;
            bool? optimize = null;
            string keyFile = null;
            bool? delaySign = null;
            bool? publicSign = null;
            bool? emitEntryPoint = null;
            bool? generateXmlDocumentation = null;
            string outputName = null;
            IReadOnlyList<string> additionalArguments = null;

            Func<string, bool?> nullableBoolConverter = v => bool.Parse(v);

            syntax.DefineOptionList(s_definesTemplate.LongName, ref defines, "Preprocessor definitions");

            syntax.DefineOptionList(s_suppressWarningTemplate.LongName, ref suppressWarnings, "Suppresses the specified warning");

            syntax.DefineOptionList(s_additionalArgumentsTemplate.LongName, ref additionalArguments, "Pass the additional argument directly to the compiler");

            syntax.DefineOption(s_debugTypeTemplate.LongName, ref debugType, "The type of PDB to emit: portable or full");

            syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion,
                    "The version of the language used to compile");

            syntax.DefineOption(s_platformTemplate.LongName, ref platform,
                    "The target platform");

            syntax.DefineOption(s_allowUnsafeTemplate.LongName, ref allowUnsafe,
                    nullableBoolConverter, "Allow unsafe code");

            syntax.DefineOption(s_warningsAsErrorsTemplate.LongName, ref warningsAsErrors,
                    nullableBoolConverter, "Turn all warnings into errors");

            syntax.DefineOption(s_optimizeTemplate.LongName, ref optimize,
                    nullableBoolConverter, "Enable compiler optimizations");

            syntax.DefineOption(s_keyFileTemplate.LongName, ref keyFile,
                    "Path to file containing the key to strong-name sign the output assembly");

            syntax.DefineOption(s_delaySignTemplate.LongName, ref delaySign,
                    nullableBoolConverter, "Delay-sign the output assembly");

            syntax.DefineOption(s_publicSignTemplate.LongName, ref publicSign,
                    nullableBoolConverter, "Public-sign the output assembly");

            syntax.DefineOption(s_emitEntryPointTemplate.LongName, ref emitEntryPoint,
                    nullableBoolConverter, "Output an executable console program");

            syntax.DefineOption(s_generateXmlDocumentation.LongName, ref generateXmlDocumentation,
                    nullableBoolConverter, "Generate XML documentation file");

            syntax.DefineOption(s_outputNameTemplate.LongName, ref outputName, "Output assembly name");

            return new CommonCompilerOptions
            {
                Defines = defines,
                SuppressWarnings = suppressWarnings,
                LanguageVersion = languageVersion,
                Platform = platform,
                AllowUnsafe = allowUnsafe,
                WarningsAsErrors = warningsAsErrors,
                Optimize = optimize,
                KeyFile = keyFile,
                DelaySign = delaySign,
                PublicSign = publicSign,
                DebugType = debugType,
                EmitEntryPoint = emitEntryPoint,
                GenerateXmlDocumentation = generateXmlDocumentation,
                OutputName = outputName,
                AdditionalArguments = additionalArguments
            };
        }
Exemplo n.º 37
0
 protected override void ParseOptions(ArgumentSyntax syntax)
 {
     syntax.DefineOption("directives", ref _directives, "Displays help for all preprocessor directives.");
 }
Exemplo n.º 38
0
        protected override void ParseOptions(ArgumentSyntax syntax)
        {
            syntax.DefineOption("w|watch", ref _watch, "Watches the input folder for any changes.");
            _preview = syntax.DefineOption("p|preview", ref _previewPort, false, "Start the preview web server on the specified port (default is " + _previewPort + ").").IsSpecified;
            if (syntax.DefineOption("force-ext", ref _previewForceExtension, "Force the use of extensions in the preview web server (by default, extensionless URLs may be used).").IsSpecified && !_preview)
            {
                syntax.ReportError("force-ext can only be specified if the preview server is running.");
            }
            if (syntax.DefineOption("preview-root", ref _previewRoot, DirectoryPath.FromString, "The path to the root of the preview server, if not the output folder.").IsSpecified && !_preview)
            {
                syntax.ReportError("preview-root can only be specified if the preview server is running.");
            }
            syntax.DefineOptionList("i|input", ref _configOptions.InputPaths, DirectoryPath.FromString, "The path(s) of input files, can be absolute or relative to the current folder.");
            syntax.DefineOption("o|output", ref _configOptions.OutputPath, DirectoryPath.FromString, "The path to output files, can be absolute or relative to the current folder.");
            syntax.DefineOption("c|config", ref _configOptions.ConfigFilePath, FilePath.FromString, "Configuration file (by default, config.wyam is used).");
            syntax.DefineOption("u|update-packages", ref _configOptions.UpdatePackages, "Check the NuGet server for more recent versions of each package and update them if applicable.");
            syntax.DefineOption("use-local-packages", ref _configOptions.UseLocalPackages, "Toggles the use of a local NuGet packages folder.");
            syntax.DefineOption("use-global-sources", ref _configOptions.UseGlobalSources, "Toggles the use of the global NuGet sources (default is false).");
            syntax.DefineOption("packages-path", ref _configOptions.PackagesPath, DirectoryPath.FromString, "The packages path to use (only if use-local is true).");
            syntax.DefineOption("output-script", ref _configOptions.OutputScript, "Outputs the config script after it's been processed for further debugging.");
            syntax.DefineOption("verify-config", ref _verifyConfig, false, "Compile the configuration but do not execute.");
            syntax.DefineOption("noclean", ref _configOptions.NoClean, "Prevents cleaning of the output path on each execution.");
            syntax.DefineOption("nocache", ref _configOptions.NoCache, "Prevents caching information during execution (less memory usage but slower execution).");

            _logFilePath = $"wyam-{DateTime.Now:yyyyMMddHHmmssfff}.txt";
            if (!syntax.DefineOption("l|log", ref _logFilePath, FilePath.FromString, false, "Log all trace messages to the specified log file (by default, wyam-[datetime].txt).").IsSpecified)
            {
                _logFilePath = null;
            }

            // Metadata
            IReadOnlyList<string> globalMetadata = null;
            if (syntax.DefineOptionList("g|global", ref globalMetadata, "Specifies global metadata as a sequence of key=value pairs.").IsSpecified)
            {
                _configOptions.GlobalMetadata = MetadataParser.Parse(globalMetadata);
            }
            IReadOnlyList<string> initialMetadata = null;
            if (syntax.DefineOptionList("initial", ref initialMetadata, "Specifies initial document metadata as a sequence of key=value pairs.").IsSpecified)
            {
                _configOptions.InitialMetadata = MetadataParser.Parse(initialMetadata);
            }
        }
Exemplo n.º 39
0
        public static AssemblyInfoOptions Parse(ArgumentSyntax syntax)
        {
            string version = null;
            string informationalVersion = null;
            string fileVersion = null;
            string title = null;
            string description = null;
            string copyright = null;
            string culture = null;
            string neutralCulture = null;
            string targetFramework = null;

            syntax.DefineOption(AssemblyVersionOptionName, ref version, UnescapeNewlines, "Assembly version");

            syntax.DefineOption(TitleOptionName, ref title, UnescapeNewlines, "Assembly title");

            syntax.DefineOption(DescriptionOptionName, ref description, UnescapeNewlines, "Assembly description");

            syntax.DefineOption(CopyrightOptionName, ref copyright, UnescapeNewlines, "Assembly copyright");

            syntax.DefineOption(NeutralCultureOptionName, ref neutralCulture, UnescapeNewlines, "Assembly neutral culture");

            syntax.DefineOption(CultureOptionName, ref culture, UnescapeNewlines, "Assembly culture");

            syntax.DefineOption(InformationalVersionOptionName, ref informationalVersion, UnescapeNewlines, "Assembly informational version");

            syntax.DefineOption(AssemblyFileVersionOptionName, ref fileVersion, UnescapeNewlines, "Assembly title");

            syntax.DefineOption(TargetFrameworkOptionName, ref targetFramework, UnescapeNewlines, "Assembly target framework");

            return new AssemblyInfoOptions()
            {
                AssemblyFileVersion = fileVersion,
                AssemblyVersion = version,
                Copyright = copyright,
                NeutralLanguage = neutralCulture,
                Description = description,
                InformationalVersion = informationalVersion,
                Title = title,
                TargetFramework = targetFramework
            };
        }