aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-23 06:05:05 -0700
committerFuwn <[email protected]>2024-10-23 06:05:05 -0700
commit49e21d633c14f639659c8ec3312bb808dec3005e (patch)
tree0d0f65a11910081f7036859ee028fe9a6dc49cfd
parentcb482154c1c9647d747cc15314f424d7be606569 (diff)
downloadyae-49e21d633c14f639659c8ec3312bb808dec3005e.tar.xz
yae-49e21d633c14f639659c8ec3312bb808dec3005e.zip
feat(yae): dry-run flag
-rw-r--r--README.md3
-rw-r--r--internal/commands/add.go4
-rw-r--r--internal/commands/drop.go4
-rw-r--r--internal/commands/init.go4
-rw-r--r--internal/commands/update.go2
-rw-r--r--yae.go4
6 files changed, 20 insertions, 1 deletions
diff --git a/README.md b/README.md
index c941d90..1af60a3 100644
--- a/README.md
+++ b/README.md
@@ -200,6 +200,9 @@ COMMANDS:
GLOBAL OPTIONS:
--sources value Sources path (default: "./yae.json")
+ --debug Enable debug output (default: false)
+ --silent Silence log output (default: false)
+ --dry-run Prevents writing to disk (default: false)
--help, -h show help
COPYRIGHT:
diff --git a/internal/commands/add.go b/internal/commands/add.go
index e32d07d..1b32533 100644
--- a/internal/commands/add.go
+++ b/internal/commands/add.go
@@ -107,6 +107,10 @@ func Add(sources *yae.Sources) func(c *cli.Context) error {
return err
}
+ if c.Bool("dry-run") {
+ return nil
+ }
+
return sources.Save(c.String("sources"))
}
}
diff --git a/internal/commands/drop.go b/internal/commands/drop.go
index 58855df..f30afb6 100644
--- a/internal/commands/drop.go
+++ b/internal/commands/drop.go
@@ -19,6 +19,10 @@ func Drop(sources *yae.Sources) func(c *cli.Context) error {
sources.Drop(c.Args().Get(0))
+ if c.Bool("dry-run") {
+ return nil
+ }
+
return sources.Save(c.String("sources"))
}
}
diff --git a/internal/commands/init.go b/internal/commands/init.go
index f38ec96..4d41553 100644
--- a/internal/commands/init.go
+++ b/internal/commands/init.go
@@ -14,6 +14,10 @@ func Init(sources *yae.Sources) func(c *cli.Context) error {
return fmt.Errorf("sources file already exists")
}
+ if c.Bool("dry-run") {
+ return nil
+ }
+
return sources.Save(c.String("sources"))
}
}
diff --git a/internal/commands/update.go b/internal/commands/update.go
index b1ce17b..fa7e09f 100644
--- a/internal/commands/update.go
+++ b/internal/commands/update.go
@@ -53,7 +53,7 @@ func Update(sources *yae.Sources) func(c *cli.Context) error {
}
}
- if len(updates) > 0 {
+ if len(updates) > 0 && !c.Bool("dry-run") {
if err := sources.Save(c.String("sources")); err != nil {
return err
}
diff --git a/yae.go b/yae.go
index d943555..c9e1c21 100644
--- a/yae.go
+++ b/yae.go
@@ -65,6 +65,10 @@ func main() {
return nil
},
},
+ &cli.BoolFlag{
+ Name: "dry-run",
+ Usage: "Prevents writing to disk",
+ },
},
Copyright: fmt.Sprintf("Copyright (c) 2024-%s Fuwn", fmt.Sprint(time.Now().Year())),
ExitErrHandler: func(c *cli.Context, err error) {