diff options
| author | Fuwn <[email protected]> | 2026-01-27 03:55:42 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-27 03:58:28 +0000 |
| commit | a391fdec036a7e2ce165516d4c38962bb12cf65e (patch) | |
| tree | a307a30a899953d975f927ed621869f2eebd927e /cmd | |
| parent | feat(config): Add '.' shorthand for current directory repository (diff) | |
| download | mugi-a391fdec036a7e2ce165516d4c38962bb12cf65e.tar.xz mugi-a391fdec036a7e2ce165516d4c38962bb12cf65e.zip | |
feat: Add repository management commands
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/mugi/main.go | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/cmd/mugi/main.go b/cmd/mugi/main.go index 3c32db6..7416760 100644 --- a/cmd/mugi/main.go +++ b/cmd/mugi/main.go @@ -6,6 +6,7 @@ import ( "github.com/ebisu/mugi/internal/cli" "github.com/ebisu/mugi/internal/config" + "github.com/ebisu/mugi/internal/manage" "github.com/ebisu/mugi/internal/ui" ) @@ -36,7 +37,49 @@ func run() error { return nil } - cfg, err := config.Load(cmd.ConfigPath) + configPath := cmd.ConfigPath + if configPath == "" { + configPath, _ = config.Path() + } + + switch cmd.Type { + case cli.CommandAdd: + cfg, err := config.Load(configPath) + if err != nil { + return fmt.Errorf("config: %w", err) + } + + if err := manage.Add(cmd.Path, configPath, cfg.Remotes); err != nil { + return err + } + + fmt.Printf("Added repository: %s\n", cmd.Path) + + return nil + + case cli.CommandRemove: + if err := manage.Remove(cmd.Repo, configPath); err != nil { + return err + } + + fmt.Printf("Removed repository: %s\n", cmd.Repo) + + return nil + + case cli.CommandList: + repos, err := manage.List(configPath) + if err != nil { + return err + } + + for _, repo := range repos { + fmt.Printf("%s (%s)\n", repo.Name, repo.Path) + } + + return nil + } + + cfg, err := config.Load(configPath) if err != nil { return fmt.Errorf("config: %w", err) } |