{"record":{"id":"f1dd3abb21dde414","repo":"chocolatey/choco","slug":"when-specifying-the-subcommand-0-you-must-als-f1dd3a","errorCode":null,"errorMessage":"When specifying the subcommand '{0}', you must also specify --name.","messagePattern":"When specifying the subcommand '(.+?)', you must also specify --name\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyTemplateCommand.cs","lineNumber":82,"sourceCode":"\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\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\r\n        {\r\n            if (configuration.TemplateCommand.Command != TemplateCommandType.List && string.IsNullOrWhiteSpace(configuration.TemplateCommand.Name))\r\n            {\r\n                throw new ApplicationException(\"When specifying the subcommand '{0}', you must also specify --name.\".FormatWith(configuration.TemplateCommand.Command.ToStringSafe().ToLower()));\r\n            }\r\n        }\r\n\r\n        public virtual void HelpMessage(ChocolateyConfiguration configuration)\r\n        {\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Template Command\");\r\n            \"chocolatey\".Log().Info(@\"\r\nList information installed templates.\r\n\r\nBoth manually installed templates and templates installed via\r\n .template packages are displayed.\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Usage\");\r\n            \"chocolatey\".Log().Info(@\"\r\n    choco template [list]|info [<options/switches>]\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Examples\");\r\n            \"chocolatey\".Log().Info(@\"\r","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyTemplateCommand.cs#L64-L100","documentation":"Thrown by ChocolateyTemplateCommand.Validate when the subcommand is not 'list' and no --name was provided. Non-list template operations (e.g. 'info') require a --name to identify which template to get information about. Without a name the operation has no target.","triggerScenarios":"Running 'choco template info' without --name=<template-name>. The condition: TemplateCommand.Command != List AND TemplateCommand.Name is empty.","commonSituations":"User runs 'choco template info' expecting a full listing (that is 'list'). User forgets to specify which template. Script omits --name due to variable issues.","solutions":["Add the --name flag: 'choco template info --name=<template-id>'.","Run 'choco template list' first to see available template names.","If you want to list all templates, use 'choco template list'."],"exampleFix":"// before\nchoco template info\n// after\nchoco template info --name=\"mytemplate\"","handlingStrategy":"validation","validationCode":"// For non-list template ops, ensure --name\nif (templateSubcommand != \"list\" && string.IsNullOrWhiteSpace(templateName))\n{\n    Console.Error.WriteLine($\"choco template {templateSubcommand} requires --name=<template>.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include --name with 'choco template info'.","Run 'choco template list' to see available template names."],"tags":["chocolatey","template-command","missing-argument","validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}