{"record":{"id":"cf02b6a810e40316","repo":"chocolatey/choco","slug":"when-specifying-the-subcommand-0-you-must-als-cf02b6","errorCode":null,"errorMessage":"When specifying the subcommand '{0}', you must also specify --name.","messagePattern":"When specifying the subcommand '(.+?)', you must also specify --name\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyFeatureCommand.cs","lineNumber":90,"sourceCode":"            if ((configuration.FeatureCommand.Command == FeatureCommandType.List\r\n                 || !string.IsNullOrWhiteSpace(configuration.FeatureCommand.Name)\r\n                )\r\n                && unparsedArguments.Count > 1)\r\n            {\r\n                throw new ApplicationException(\"A single feature command must be listed. Please see the help menu for those commands.\");\r\n            }\r\n\r\n            if (string.IsNullOrWhiteSpace(configuration.FeatureCommand.Name) && unparsedArguments.Count >= 2)\r\n            {\r\n                configuration.FeatureCommand.Name = unparsedArguments[1];\r\n            }\r\n        }\r\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\r\n        {\r\n            if (configuration.FeatureCommand.Command != FeatureCommandType.List && string.IsNullOrWhiteSpace(configuration.FeatureCommand.Name))\r\n            {\r\n                throw new ApplicationException(\"When specifying the subcommand '{0}', you must also specify --name.\".FormatWith(configuration.FeatureCommand.Command.ToStringSafe().ToLower()));\r\n            }\r\n        }\r\n\r\n        public virtual void HelpMessage(ChocolateyConfiguration configuration)\r\n        {\r\n            this.Log().Info(ChocolateyLoggers.Important, \"Feature Command\");\r\n            this.Log().Info(@\"\r\nChocolatey will allow you to interact with features.\r\n\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Usage\");\r\n            \"chocolatey\".Log().Info(@\"\r\n    choco feature [list]|disable|enable [<options/switches>]\r\n\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Examples\");\r\n            \"chocolatey\".Log().Info(@\"\r\n    choco feature\r","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyFeatureCommand.cs#L72-L108","documentation":"Validate() requires a feature name for any feature subcommand other than List. If FeatureCommand.Command != List and configuration.FeatureCommand.Name is blank, it throws, naming the offending subcommand. enable/disable need to know which feature to toggle.","triggerScenarios":"Running 'choco feature enable' or 'choco feature disable' without --name and without a positional name token.","commonSituations":"Forgetting the feature name; assuming a bare subcommand toggles all features; the name token getting parsed as a flag.","solutions":["Add --name <feature> (or a positional name): 'choco feature disable -n checkSumFiles'.","Run 'choco feature list' to discover valid feature names first.","Quote names containing dashes to avoid flag interpretation."],"exampleFix":"# before\nchoco feature enable\n\n# after\nchoco feature enable --name useEnhancedExitCodes","handlingStrategy":"validation","validationCode":"// Non-list feature subcommands require a name.\nif (featureVerb != \"list\" && string.IsNullOrWhiteSpace(featureName))\n{\n    throw new InvalidOperationException($\"feature {featureVerb} requires --name\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --name for enable/disable.","Quote feature names containing dashes."],"tags":["feature","validation","name","enable-disable"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}