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 /yae.go | |
| parent | 0aeae8d523ecb762e296b938cff3e012551e27b7 (diff) | |
| download | yae-4353451af2a6edeeca75f5a87186d40d5e81159a.tar.xz yae-4353451af2a6edeeca75f5a87186d40d5e81159a.zip | |
refactor(commands): move flags to commands package
Diffstat (limited to 'yae.go')
| -rw-r--r-- | yae.go | 63 |
1 files changed, 4 insertions, 59 deletions
@@ -75,46 +75,8 @@ func main() { Args: true, ArgsUsage: "<name> <url>", Usage: "Add a source", - Flags: []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", - }, - }, - Action: commands.Add(&sources), + Flags: commands.AddFlags(), + Action: commands.Add(&sources), }, { Name: "drop", @@ -127,25 +89,8 @@ func main() { Args: true, Usage: "Update one or all sources", ArgsUsage: "[name]", - Flags: []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)", - }, - }, - Action: commands.Update(&sources), + Flags: commands.UpdateFlags(), + Action: commands.Update(&sources), }, }, }).Run(os.Args); err != nil { |