fix: Detect both unknown flag and commands

This commit is contained in:
Yoftahe 2026-02-25 02:18:43 +03:00
parent ebde4cd640
commit e43b05df55
3 changed files with 22 additions and 0 deletions

View file

@ -25,6 +25,14 @@ func authCmd() {
return
}
subcommand := os.Args[2]
if strings.HasPrefix(subcommand, "-") {
fmt.Printf("Error: %s is an unknown flag\n", subcommand)
authHelp()
os.Exit(1)
}
switch os.Args[2] {
case "login":
authLoginCmd()

View file

@ -7,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"
"github.com/sipeed/picoclaw/pkg/cron"
@ -20,6 +21,12 @@ func cronCmd() {
subcommand := os.Args[2]
if strings.HasPrefix(subcommand, "-") {
fmt.Printf("Error: %s is an unknown flag\n", subcommand)
cronHelp()
os.Exit(1)
}
// Load config to get workspace path
cfg, err := loadConfig()
if err != nil {

View file

@ -12,6 +12,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"github.com/sipeed/picoclaw/pkg/config"
"github.com/sipeed/picoclaw/pkg/skills"
@ -123,6 +124,12 @@ func main() {
subcommand := os.Args[2]
if strings.HasPrefix(subcommand, "-") {
fmt.Printf("Error: %s is an unknown flag\n", subcommand)
skillsHelp()
os.Exit(1)
}
cfg, err := loadConfig()
if err != nil {
fmt.Printf("Error loading config: %v\n", err)