aboutsummaryrefslogtreecommitdiff
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
parentrefactor!: wiene -> yae (diff)
downloadyae-8daa0742b7268a94dac4076311cfe4e0323cbe60.tar.xz
yae-8daa0742b7268a94dac4076311cfe4e0323cbe60.zip
feat(yae): add init sub-command
-rw-r--r--.gitignore4
-rw-r--r--README.md1
-rw-r--r--yae.go15
3 files changed, 18 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 6758bf2..ee13815 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-wiene
+yae
.pre-commit-config.yaml
result
-wiene.json
+yae.json
diff --git a/README.md b/README.md
index dfb9ba7..56c9655 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@ AUTHOR:
COMMANDS:
+ init Initialise a new Yae environment
add Add a source
drop Drop a source
update Update one or all sources
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>",