{"record":{"id":"1defd96103c44756","repo":"chocolatey/choco","slug":"a-single-template-command-must-be-listed-please-s","errorCode":null,"errorMessage":"A single template command must be listed. Please see the help menu for those commands","messagePattern":"A single template 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/ChocolateyTemplateCommand.cs","lineNumber":58,"sourceCode":"            _templateService = templateService;\r\n        }\r\n\r\n        public void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfiguration configuration)\r\n        {\r\n            optionSet\r\n                .Add(\"n=|name=\",\r\n                    \"The name of the template to get information about.\",\r\n                    option => configuration.TemplateCommand.Name = option.UnquoteSafe().ToLower());\r\n            // todo: #2570 Allow for templates from an external path? Requires #1477\r\n        }\r\n\r\n        public virtual void ParseAdditionalArguments(IList<string> unparsedArguments, ChocolateyConfiguration configuration)\r\n        {\r\n            // don't set configuration.Input or it will be passed to list\r\n\r\n            if (unparsedArguments.Count > 1)\r\n            {\r\n                throw new ApplicationException(\"A single template command must be listed. Please see the help menu for those commands\");\r\n            }\r\n\r\n            var command = TemplateCommandType.Unknown;\r\n            var unparsedCommand = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault();\r\n            Enum.TryParse(unparsedCommand, true, out command);\r\n\r\n            if (command == TemplateCommandType.Unknown)\r\n            {\r\n                if (!string.IsNullOrWhiteSpace(unparsedCommand))\r\n                {\r\n                    this.Log().Warn(\"Unknown command {0}. Setting to list.\".FormatWith(unparsedCommand));\r\n                }\r\n\r\n                command = TemplateCommandType.List;\r\n            }\r\n\r\n            configuration.TemplateCommand.Command = command;\r\n        }\r","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyTemplateCommand.cs#L40-L76","documentation":"Thrown by ChocolateyTemplateCommand.ParseAdditionalArguments when more than one unparsed positional argument is passed to 'choco template'. The template command accepts exactly one subcommand verb (list, info); passing two or more positional tokens is ambiguous and rejected before subcommand parsing.","triggerScenarios":"Running 'choco template list info' or any invocation with 2+ positional arguments. The check is unparsedArguments.Count > 1.","commonSituations":"User chains multiple template operations. Script misconfiguration passes extra positional args. User misunderstands CLI syntax.","solutions":["Pass only a single template subcommand per invocation: 'choco template list' or 'choco template info'.","For multiple operations, issue separate 'choco template' calls.","Run 'choco template --help' to review accepted subcommands."],"exampleFix":"// before\nchoco template list info\n// after\nchoco template list\nchoco template info --name=mytemplate","handlingStrategy":"validation","validationCode":"// Ensure only one positional subcommand\nif (positionalArgs.Count(arg => !arg.StartsWith(\"-\")) > 1)\n{\n    Console.Error.WriteLine(\"Pass a single template subcommand (list or info).\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Issue each template operation as a separate 'choco template <subcommand>' call.","Validate argument count before invoking."],"tags":["chocolatey","template-command","argument-validation","cli-usage"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}