Example #1
0
        private static string GetPositionalArgumentHelp(UsageParameter usageParameter, CommandDefinition commandDefinition)
        {
            if (commandDefinition.Command == "docker secret create" && usageParameter.RawValue == "[file|-]")
            {
                return("Path to file to create the secret from.");
            }

            if (commandDefinition.Command == "docker config create" && usageParameter.RawValue == "[file|-]")
            {
                return("Path to file to create the config from.");
            }

            if (usageParameter.RawValue == "PATH|URL|-")
            {
                return("Path or url where the build context is located.");
            }
            return(usageParameter.RawValue.RemoveNewLines());
        }
Example #2
0
        public static List <UsageParameter> Parse(string[] parameters)
        {
            var usageParameters = new List <UsageParameter>();

            for (var i = 0; i < parameters.Length; i++)
            {
                var value = parameters[i];
                while (parameters.Length > i + 1 && parameters[i + 1] == "|")
                {
                    value += parameters[i + 1] + parameters[i + 2];
                    i     += 2;
                }

                var usage = new UsageParameter();

                var match = Regex.Match(value, @"^\[?([A-Z]+)=([A-Z]+)(?:\.\.\.\])?$");
                if (match.Success)
                {
                    usage.IsDictionary = true;
                    if (!value.StartsWith("[") &&
                        parameters.Length > i + 1 &&
                        parameters[i + 1] == $"[{match.Groups[groupnum: 1].Value}={match.Groups[groupnum: 2].Value}...]")