⛩️ Powerful yet Minimal Nix Dependency Manager
flake flakes home-manager nixos go nix dependency dependencies
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(commands): move flags to commands package

Fuwn 22b927bf 3dd9f302

+67 -59
+42
internal/commands/add.go
··· 8 8 "github.com/urfave/cli/v2" 9 9 ) 10 10 11 + func AddFlags() []cli.Flag { 12 + return []cli.Flag{ 13 + &cli.BoolFlag{ 14 + Name: "unpack", 15 + Usage: "Unpack the source into the Nix Store", 16 + Value: true, 17 + }, 18 + &cli.StringFlag{ 19 + Name: "type", 20 + Usage: "Source type", 21 + Required: true, 22 + Action: func(c *cli.Context, value string) error { 23 + if value != "binary" && value != "git" { 24 + return fmt.Errorf("invalid source type: must be 'binary' or 'git'") 25 + } 26 + 27 + return nil 28 + }, 29 + }, 30 + &cli.StringFlag{ 31 + Name: "version", 32 + Usage: "Source version used in identifying latest git source", 33 + }, 34 + &cli.StringFlag{ 35 + Name: "tag-predicate", 36 + Usage: "Git tag predicate used in identifying latest git source", 37 + }, 38 + &cli.StringFlag{ 39 + Name: "trim-tag-prefix", 40 + Usage: "A prefix to trim from remote git tags", 41 + }, 42 + &cli.BoolFlag{ 43 + Name: "pin", 44 + Usage: "Prevent the source from being updated", 45 + }, 46 + &cli.BoolFlag{ 47 + Name: "force", 48 + Usage: "Always force update the source, regardless of unchanged remote tag", 49 + }, 50 + } 51 + } 52 + 11 53 func Add(sources *yae.Sources) func(c *cli.Context) error { 12 54 return func(c *cli.Context) error { 13 55 if c.Args().Len() != 2 {
+21
internal/commands/update.go
··· 7 7 "github.com/urfave/cli/v2" 8 8 ) 9 9 10 + func UpdateFlags() []cli.Flag { 11 + return []cli.Flag{ 12 + &cli.BoolFlag{ 13 + Name: "output-updated-list", 14 + Usage: "Output a newline-seperated list of updated sources, regardless of silent mode", 15 + }, 16 + &cli.BoolFlag{ 17 + Name: "output-formatted-updated-list", 18 + Usage: "Output a comma and/or ampersand list of updated sources, regardless of silent mode", 19 + }, 20 + &cli.BoolFlag{ 21 + Name: "force-hashed", 22 + Usage: "Force updates for non-pinned sources that have an unchanged version (recalculate hash)", 23 + }, 24 + &cli.BoolFlag{ 25 + Name: "force-pinned", 26 + Usage: "Force updates for all sources, including pinned sources (can be used with --force-hashed)", 27 + }, 28 + } 29 + } 30 + 10 31 func Update(sources *yae.Sources) func(c *cli.Context) error { 11 32 return func(c *cli.Context) error { 12 33 updates := []string{}
+4 -59
yae.go
··· 75 75 Args: true, 76 76 ArgsUsage: "<name> <url>", 77 77 Usage: "Add a source", 78 - Flags: []cli.Flag{ 79 - &cli.BoolFlag{ 80 - Name: "unpack", 81 - Usage: "Unpack the source into the Nix Store", 82 - Value: true, 83 - }, 84 - &cli.StringFlag{ 85 - Name: "type", 86 - Usage: "Source type", 87 - Required: true, 88 - Action: func(c *cli.Context, value string) error { 89 - if value != "binary" && value != "git" { 90 - return fmt.Errorf("invalid source type: must be 'binary' or 'git'") 91 - } 92 - 93 - return nil 94 - }, 95 - }, 96 - &cli.StringFlag{ 97 - Name: "version", 98 - Usage: "Source version used in identifying latest git source", 99 - }, 100 - &cli.StringFlag{ 101 - Name: "tag-predicate", 102 - Usage: "Git tag predicate used in identifying latest git source", 103 - }, 104 - &cli.StringFlag{ 105 - Name: "trim-tag-prefix", 106 - Usage: "A prefix to trim from remote git tags", 107 - }, 108 - &cli.BoolFlag{ 109 - Name: "pin", 110 - Usage: "Prevent the source from being updated", 111 - }, 112 - &cli.BoolFlag{ 113 - Name: "force", 114 - Usage: "Always force update the source, regardless of unchanged remote tag", 115 - }, 116 - }, 117 - Action: commands.Add(&sources), 78 + Flags: commands.AddFlags(), 79 + Action: commands.Add(&sources), 118 80 }, 119 81 { 120 82 Name: "drop", ··· 127 89 Args: true, 128 90 Usage: "Update one or all sources", 129 91 ArgsUsage: "[name]", 130 - Flags: []cli.Flag{ 131 - &cli.BoolFlag{ 132 - Name: "output-updated-list", 133 - Usage: "Output a newline-seperated list of updated sources, regardless of silent mode", 134 - }, 135 - &cli.BoolFlag{ 136 - Name: "output-formatted-updated-list", 137 - Usage: "Output a comma and/or ampersand list of updated sources, regardless of silent mode", 138 - }, 139 - &cli.BoolFlag{ 140 - Name: "force-hashed", 141 - Usage: "Force updates for non-pinned sources that have an unchanged version (recalculate hash)", 142 - }, 143 - &cli.BoolFlag{ 144 - Name: "force-pinned", 145 - Usage: "Force updates for all sources, including pinned sources (can be used with --force-hashed)", 146 - }, 147 - }, 148 - Action: commands.Update(&sources), 92 + Flags: commands.UpdateFlags(), 93 + Action: commands.Update(&sources), 149 94 }, 150 95 }, 151 96 }).Run(os.Args); err != nil {