aboutsummaryrefslogtreecommitdiff
path: root/yae.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-11 04:19:59 +0000
committerFuwn <[email protected]>2024-10-11 04:19:59 +0000
commit8daa0742b7268a94dac4076311cfe4e0323cbe60 (patch)
tree3af2a3c86b5728e37c625f52ce62425e38cf59b4 /yae.go
parentrefactor!: wiene -> yae (diff)
downloadyae-8daa0742b7268a94dac4076311cfe4e0323cbe60.tar.xz
yae-8daa0742b7268a94dac4076311cfe4e0323cbe60.zip
feat(yae): add init sub-command
Diffstat (limited to 'yae.go')
-rw-r--r--yae.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/yae.go b/yae.go
index baf1a9a..5c6cd79 100644
--- a/yae.go
+++ b/yae.go
@@ -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>",