diff options
| author | Fuwn <[email protected]> | 2024-10-13 01:14:49 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-13 01:14:49 -0700 |
| commit | 4353451af2a6edeeca75f5a87186d40d5e81159a (patch) | |
| tree | d3f8915a08a88f417056c2e005afe508e0484e1e /internal | |
| parent | 0aeae8d523ecb762e296b938cff3e012551e27b7 (diff) | |
| download | yae-4353451af2a6edeeca75f5a87186d40d5e81159a.tar.xz yae-4353451af2a6edeeca75f5a87186d40d5e81159a.zip | |
refactor(commands): move flags to commands package
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/commands/add.go | 42 | ||||
| -rw-r--r-- | internal/commands/update.go | 21 |
2 files changed, 63 insertions, 0 deletions
diff --git a/internal/commands/add.go b/internal/commands/add.go index 4ee15ec..e32d07d 100644 --- a/internal/commands/add.go +++ b/internal/commands/add.go @@ -8,6 +8,48 @@ import ( "github.com/urfave/cli/v2" ) +func AddFlags() []cli.Flag { + return []cli.Flag{ + &cli.BoolFlag{ + Name: "unpack", + Usage: "Unpack the source into the Nix Store", + Value: true, + }, + &cli.StringFlag{ + Name: "type", + Usage: "Source type", + Required: true, + Action: func(c *cli.Context, value string) error { + if value != "binary" && value != "git" { + return fmt.Errorf("invalid source type: must be 'binary' or 'git'") + } + + return nil + }, + }, + &cli.StringFlag{ + Name: "version", + Usage: "Source version used in identifying latest git source", + }, + &cli.StringFlag{ + Name: "tag-predicate", + Usage: "Git tag predicate used in identifying latest git source", + }, + &cli.StringFlag{ + Name: "trim-tag-prefix", + Usage: "A prefix to trim from remote git tags", + }, + &cli.BoolFlag{ + Name: "pin", + Usage: "Prevent the source from being updated", + }, + &cli.BoolFlag{ + Name: "force", + Usage: "Always force update the source, regardless of unchanged remote tag", + }, + } +} + func Add(sources *yae.Sources) func(c *cli.Context) error { return func(c *cli.Context) error { if c.Args().Len() != 2 { diff --git a/internal/commands/update.go b/internal/commands/update.go index 66ccfb3..b1ce17b 100644 --- a/internal/commands/update.go +++ b/internal/commands/update.go @@ -7,6 +7,27 @@ import ( "github.com/urfave/cli/v2" ) +func UpdateFlags() []cli.Flag { + return []cli.Flag{ + &cli.BoolFlag{ + Name: "output-updated-list", + Usage: "Output a newline-seperated list of updated sources, regardless of silent mode", + }, + &cli.BoolFlag{ + Name: "output-formatted-updated-list", + Usage: "Output a comma and/or ampersand list of updated sources, regardless of silent mode", + }, + &cli.BoolFlag{ + Name: "force-hashed", + Usage: "Force updates for non-pinned sources that have an unchanged version (recalculate hash)", + }, + &cli.BoolFlag{ + Name: "force-pinned", + Usage: "Force updates for all sources, including pinned sources (can be used with --force-hashed)", + }, + } +} + func Update(sources *yae.Sources) func(c *cli.Context) error { return func(c *cli.Context) error { updates := []string{} |