fix: Detect both unknown flag and commands
This commit is contained in:
parent
ebde4cd640
commit
e43b05df55
3 changed files with 22 additions and 0 deletions
|
|
@ -25,6 +25,14 @@ func authCmd() {
|
||||||
return
|
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] {
|
switch os.Args[2] {
|
||||||
case "login":
|
case "login":
|
||||||
authLoginCmd()
|
authLoginCmd()
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sipeed/picoclaw/pkg/cron"
|
"github.com/sipeed/picoclaw/pkg/cron"
|
||||||
|
|
@ -20,6 +21,12 @@ func cronCmd() {
|
||||||
|
|
||||||
subcommand := os.Args[2]
|
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
|
// Load config to get workspace path
|
||||||
cfg, err := loadConfig()
|
cfg, err := loadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/sipeed/picoclaw/pkg/config"
|
"github.com/sipeed/picoclaw/pkg/config"
|
||||||
"github.com/sipeed/picoclaw/pkg/skills"
|
"github.com/sipeed/picoclaw/pkg/skills"
|
||||||
|
|
@ -123,6 +124,12 @@ func main() {
|
||||||
|
|
||||||
subcommand := os.Args[2]
|
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()
|
cfg, err := loadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error loading config: %v\n", err)
|
fmt.Printf("Error loading config: %v\n", err)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue