mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
73f27803d4
* refactor(cli): migrate to Cobra-based command structure Refactor CLI to use Cobra instead of manual os.Args parsing. - Introduce root command and structured subcommands under cmd/picoclaw/internal - Convert agent, auth, cron, gateway, migrate, onboard, skills, status and version to Cobra commands - Replace manual flag parsing with Cobra flags - Remove direct os.Args usage from command handlers - Keep existing command behavior and output semantics This change focuses on CLI structure and maintainability. No business logic changes intended. * chore(cli): remove version2 alias and make cobra a direct dependency * test(cli): add basic command tests - Add tests for CLI command tree and flag parsing - Align LDFLAGS injection path for version info - Remove unused manual help function * test: migrate command tests to testify assertions Replace standard library testing error checks (t.Error*, t.Fatalf) with assert/require from stretchr/testify across all cobra command tests for improved readability and consistency. * fix(cli): make linter happy * test: avoid duplication in windows config path test * test: simplify allowed command checks using slices.Contains * fix(skills): register subcommands during command construction - Move subcommand registration out of PersistentPreRunE - Ensure `picoclaw skills <subcommand>` resolves correctly - Minor install command and test cleanups * refactor(cli): address review feedback and improve command clarity * fix(authLogoutCmd): rm os.Exit
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
// PicoClaw - Ultra-lightweight personal AI agent
|
|
// Inspired by and based on nanobot: https://github.com/HKUDS/nanobot
|
|
// License: MIT
|
|
//
|
|
// Copyright (c) 2026 PicoClaw contributors
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/agent"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/auth"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/cron"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/gateway"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/migrate"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/onboard"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/skills"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/status"
|
|
"github.com/sipeed/picoclaw/cmd/picoclaw/internal/version"
|
|
)
|
|
|
|
func NewPicoclawCommand() *cobra.Command {
|
|
short := fmt.Sprintf("%s picoclaw - Personal AI Assistant v%s\n\n", internal.Logo, internal.GetVersion())
|
|
|
|
cmd := &cobra.Command{
|
|
Use: "picoclaw",
|
|
Short: short,
|
|
Example: "picoclaw list",
|
|
}
|
|
|
|
cmd.AddCommand(
|
|
onboard.NewOnboardCommand(),
|
|
agent.NewAgentCommand(),
|
|
auth.NewAuthCommand(),
|
|
gateway.NewGatewayCommand(),
|
|
status.NewStatusCommand(),
|
|
cron.NewCronCommand(),
|
|
migrate.NewMigrateCommand(),
|
|
skills.NewSkillsCommand(),
|
|
version.NewVersionCommand(),
|
|
)
|
|
|
|
return cmd
|
|
}
|
|
|
|
func main() {
|
|
cmd := NewPicoclawCommand()
|
|
if err := cmd.Execute(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|