{"record":{"id":"7399bfaf76c85546","repo":"chocolatey/choco","slug":"a-single-license-command-must-be-listed-please-se","errorCode":null,"errorMessage":"A single license command must be listed. Please see the help menu for those commands","messagePattern":"A single license command must be listed\\. Please see the help menu for those commands","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyLicenseCommand.cs","lineNumber":45,"sourceCode":"using System.Text.RegularExpressions;\r\n\r\nnamespace chocolatey.infrastructure.app.commands\r\n{\r\n    [CommandFor(\"license\", \"display Chocolatey license information\", Version = \"2.5.0\")]\r\n    public class ChocolateyLicenseCommand : ChocolateyCommandBase, ICommand\r\n    {\r\n        private static readonly Regex _licenseCountRegex = new Regex(@\"\\[.*?(?<licensedMachineCount>\\d+).*?\\]\");\r\n\r\n        public void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfiguration configuration)\r\n        {\r\n            // We don't currently expect to have any arguments\r\n        }\r\n\r\n        public void ParseAdditionalArguments(IList<string> unparsedArguments, ChocolateyConfiguration configuration)\r\n        {\r\n            if (unparsedArguments.Count > 1)\r\n            {\r\n                throw new ApplicationException(\"A single license command must be listed. Please see the help menu for those commands\");\r\n            }\r\n\r\n            var command = LicenseCommandType.Unknown;\r\n            var unparsedCommand = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault();\r\n            Enum.TryParse(unparsedCommand, true, out command);\r\n\r\n            if (command == LicenseCommandType.Unknown)\r\n            {\r\n                if (!string.IsNullOrWhiteSpace(unparsedCommand))\r\n                {\r\n                    this.Log().Warn(\"Unknown command {0}. Setting to info.\".FormatWith(unparsedCommand));\r\n                }\r\n\r\n                command = LicenseCommandType.Info;\r\n            }\r\n\r\n            configuration.LicenseCommand.Command = command;\r\n        }\r","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyLicenseCommand.cs#L27-L63","documentation":"The license command accepts at most one positional subcommand. ParseAdditionalArguments throws when unparsedArguments.Count > 1, because multiple leftover positional tokens are ambiguous. It directs the user to the help menu for the single license subcommands (info).","triggerScenarios":"Running 'choco license info extra' or any license invocation leaving more than one unparsed positional token.","commonSituations":"Passing multiple license arguments; misparsing options as positionals; scripting that concatenates tokens.","solutions":["Pass a single license subcommand: 'choco license info'.","Run 'choco license -?' to confirm supported subcommands.","Check that quoted strings don't leave stray positional tokens."],"exampleFix":"# before\nchoco license info extra\n\n# after\nchoco license info","handlingStrategy":"validation","validationCode":"// License command: single positional argument max.\nvar positional = tokens.Where(t => !t.StartsWith(\"-\")).ToList();\nif (positional.Count > 1)\n{\n    throw new ArgumentException(\"license: too many positional arguments\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass a single license subcommand.","Run 'choco license -?' to confirm supported subcommands."],"tags":["license","arguments","cli","validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}