diff options
| author | Fuwn <[email protected]> | 2024-10-11 04:19:59 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-11 04:19:59 +0000 |
| commit | 8daa0742b7268a94dac4076311cfe4e0323cbe60 (patch) | |
| tree | 3af2a3c86b5728e37c625f52ce62425e38cf59b4 | |
| parent | refactor!: wiene -> yae (diff) | |
| download | yae-8daa0742b7268a94dac4076311cfe4e0323cbe60.tar.xz yae-8daa0742b7268a94dac4076311cfe4e0323cbe60.zip | |
feat(yae): add init sub-command
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | yae.go | 15 |
3 files changed, 18 insertions, 2 deletions
@@ -1,4 +1,4 @@ -wiene +yae .pre-commit-config.yaml result -wiene.json +yae.json @@ -28,6 +28,7 @@ AUTHOR: Fuwn <[email protected]> COMMANDS: + init Initialise a new Yae environment add Add a source drop Drop a source update Update one or all sources @@ -25,6 +25,10 @@ func main() { }, }, Before: func(c *cli.Context) error { + if args := c.Args(); args.Len() == 1 && args.Get(0) == "init" { + return nil + } + return sources.Load(c.String("sources")) }, Flags: []cli.Flag{ @@ -43,6 +47,17 @@ func main() { Suggest: true, Commands: []*cli.Command{ { + Name: "init", + Usage: "Initialise a new Yae environment", + Action: func(c *cli.Context) error { + if _, err := os.Stat(c.String("sources")); err == nil { + return fmt.Errorf("sources file already exists") + } + + return sources.Save(c.String("sources")) + }, + }, + { Name: "add", Args: true, ArgsUsage: "<name> <uri>", |