fix: error on unknown flags, standardize help format, move skills dispatch

Fixes #581: agent and gateway commands now error on unknown flags instead
of silently ignoring them.

Fixes #582: auth, cron, and skills help text now includes Usage header
and --help in flags list, matching doctor command format.

Fixes #585: skills subcommand dispatch moved from main.go to cmd_skills.go
via new skillsCmd() function.
This commit is contained in:
Rahul Bansal 2026-02-21 10:34:04 +05:30
parent b6a71c62c4
commit d6e609055a
5 changed files with 84 additions and 2 deletions

View file

@ -59,6 +59,10 @@ func agentCmd() {
modelOverride = args[i+1] modelOverride = args[i+1]
i++ i++
} }
default:
fmt.Printf("Unknown flag: %s\n", args[i])
fmt.Println("Run 'picoclaw agent --help' for usage.")
os.Exit(1)
} }
} }

View file

@ -43,7 +43,11 @@ func authCmd() {
} }
func authHelp() { func authHelp() {
fmt.Println("\nAuth commands:") fmt.Println("Usage: picoclaw auth <command>")
fmt.Println()
fmt.Println("Manage authentication credentials.")
fmt.Println()
fmt.Println("Commands:")
fmt.Println(" login Login via OAuth or paste token") fmt.Println(" login Login via OAuth or paste token")
fmt.Println(" logout Remove stored credentials") fmt.Println(" logout Remove stored credentials")
fmt.Println(" status Show current auth status") fmt.Println(" status Show current auth status")
@ -66,6 +70,9 @@ func authHelp() {
fmt.Println(" picoclaw auth models") fmt.Println(" picoclaw auth models")
fmt.Println(" picoclaw auth logout --provider openai") fmt.Println(" picoclaw auth logout --provider openai")
fmt.Println(" picoclaw auth status") fmt.Println(" picoclaw auth status")
fmt.Println()
fmt.Println("Flags:")
fmt.Println(" -h, --help Show this help")
} }
func authLoginCmd() { func authLoginCmd() {

View file

@ -72,6 +72,9 @@ func cronHelp() {
fmt.Println(" -d, --deliver Deliver response to channel") fmt.Println(" -d, --deliver Deliver response to channel")
fmt.Println(" --to Recipient for delivery") fmt.Println(" --to Recipient for delivery")
fmt.Println(" --channel Channel for delivery") fmt.Println(" --channel Channel for delivery")
fmt.Println()
fmt.Println("Flags:")
fmt.Println(" -h, --help Show this help")
} }
func cronListCmd(storePath string) { func cronListCmd(storePath string) {

View file

@ -44,6 +44,10 @@ func gatewayCmd() {
case "--debug", "-d": case "--debug", "-d":
logger.SetLevel(logger.DEBUG) logger.SetLevel(logger.DEBUG)
fmt.Println("🔍 Debug mode enabled") fmt.Println("🔍 Debug mode enabled")
default:
fmt.Printf("Unknown flag: %s\n", arg)
fmt.Println("Run 'picoclaw gateway --help' for usage.")
os.Exit(1)
} }
} }

View file

@ -16,8 +16,69 @@ import (
"github.com/sipeed/picoclaw/pkg/utils" "github.com/sipeed/picoclaw/pkg/utils"
) )
func skillsCmd() {
if len(os.Args) < 3 {
skillsHelp()
return
}
subcommand := os.Args[2]
if subcommand == "--help" || subcommand == "-h" {
skillsHelp()
return
}
cfg, err := loadConfig()
if err != nil {
fmt.Printf("Error loading config: %v\n", err)
fmt.Println("Run 'picoclaw doctor' to check for common problems.")
os.Exit(1)
}
workspace := cfg.WorkspacePath()
installer := skills.NewSkillInstaller(workspace)
// Get global config dir and builtin skills dir
globalDir := filepath.Dir(getConfigPath())
globalSkillsDir := filepath.Join(globalDir, "skills")
builtinSkillsDir := filepath.Join(globalDir, "picoclaw", "skills")
skillsLoader := skills.NewSkillsLoader(workspace, globalSkillsDir, builtinSkillsDir)
switch subcommand {
case "list":
skillsListCmd(skillsLoader)
case "install":
skillsInstallCmd(installer, cfg)
case "remove", "uninstall":
if len(os.Args) < 4 {
fmt.Println("Usage: picoclaw skills remove <skill-name>")
return
}
skillsRemoveCmd(installer, os.Args[3])
case "install-builtin":
skillsInstallBuiltinCmd(workspace)
case "list-builtin":
skillsListBuiltinCmd()
case "search":
skillsSearchCmd(installer)
case "show":
if len(os.Args) < 4 {
fmt.Println("Usage: picoclaw skills show <skill-name>")
return
}
skillsShowCmd(skillsLoader, os.Args[3])
default:
fmt.Printf("Unknown skills command: %s\n", subcommand)
skillsHelp()
}
}
func skillsHelp() { func skillsHelp() {
fmt.Println("\nSkills commands:") fmt.Println("Usage: picoclaw skills <command>")
fmt.Println()
fmt.Println("Manage skills (install, list, remove).")
fmt.Println()
fmt.Println("Commands:")
fmt.Println(" list List installed skills") fmt.Println(" list List installed skills")
fmt.Println(" install <repo> Install skill from GitHub") fmt.Println(" install <repo> Install skill from GitHub")
fmt.Println(" install-builtin Install all builtin skills to workspace") fmt.Println(" install-builtin Install all builtin skills to workspace")
@ -33,6 +94,9 @@ func skillsHelp() {
fmt.Println(" picoclaw skills list-builtin") fmt.Println(" picoclaw skills list-builtin")
fmt.Println(" picoclaw skills remove weather") fmt.Println(" picoclaw skills remove weather")
fmt.Println(" picoclaw skills install --registry clawhub github") fmt.Println(" picoclaw skills install --registry clawhub github")
fmt.Println()
fmt.Println("Flags:")
fmt.Println(" -h, --help Show this help")
} }
func skillsListCmd(loader *skills.SkillsLoader) { func skillsListCmd(loader *skills.SkillsLoader) {