{"record":{"id":"9d4b36ff02037d7b","repo":"sipeed/picoclaw","slug":"when-registry-is-set-exactly-1-argument-is-requ","errorCode":null,"errorMessage":"when --registry is set, exactly 1 argument is required: <slug>","messagePattern":"when --registry is set, exactly 1 argument is required: <slug>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/picoclaw/internal/skills/install.go","lineNumber":24,"sourceCode":"\t\"github.com/spf13/cobra\"\n\n\t\"github.com/sipeed/picoclaw/cmd/picoclaw/internal\"\n)\n\nfunc newInstallCommand() *cobra.Command {\n\tvar registry string\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"install\",\n\t\tShort: \"Install skill from GitHub or a registry\",\n\t\tExample: `\npicoclaw skills install sipeed/picoclaw-skills/weather\npicoclaw skills install --registry clawhub github\n`,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\tif registry != \"\" {\n\t\t\t\tif len(args) != 1 {\n\t\t\t\t\treturn fmt.Errorf(\"when --registry is set, exactly 1 argument is required: <slug>\")\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn fmt.Errorf(\"exactly 1 argument is required: <github>\")\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t\tRunE: func(_ *cobra.Command, args []string) error {\n\t\t\tcfg, err := internal.LoadConfig()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif registry != \"\" {\n\t\t\t\treturn skillsInstallFromRegistry(cfg, registry, args[0])\n\t\t\t}","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/skills/install.go#L6-L42","documentation":"Cobra Args validator for `picoclaw skills install`: when --registry is set, exactly one positional argument (the registry slug) must follow. Passing zero arguments or more than one together with --registry produces this usage error before RunE executes.","triggerScenarios":"`picoclaw skills install --registry clawhub` (no slug), `picoclaw skills install --registry clawhub weather extra` (two args), or quoting mistakes that split one slug into several words.","commonSituations":"Assuming --registry alone lists or initializes registries; passing a URL with spaces unquoted; scripts forwarding \"$@\" where extra flags land as positional args.","solutions":["Supply exactly one slug: `picoclaw skills install --registry clawhub github`","Quote slugs containing spaces or special characters as one argument","In scripts, pass the slug explicitly rather than \"$@\""],"exampleFix":"# before\npicoclaw skills install --registry clawhub\n\n# after\npicoclaw skills install --registry clawhub github","handlingStrategy":"validation","validationCode":"if registry != \"\" && len(args) != 1 {\n    return fmt.Errorf(\"usage: picoclaw skills install --registry <name> <slug>\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build command strings in code with explicit argument counts","Quote slugs so they arrive as a single shell word","Show the command's Example block when constructing user guidance"],"tags":["cli","argument-validation","skills","usage"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}