()
| 15 | ) |
| 16 | |
| 17 | func globalCmd() *cobra.Command { |
| 18 | globalCmd := &cobra.Command{} |
| 19 | persistentPreRunE := setGlobalConfigForDelegatedCommands(globalCmd) |
| 20 | *globalCmd = cobra.Command{ |
| 21 | Use: "global", |
| 22 | Short: "Manage global devbox packages", |
| 23 | // PersistentPreRunE is inherited only if children do not implement it |
| 24 | // (i.e. it's not chained). So this is fragile. Ideally we stop |
| 25 | // using PersistentPreRunE. For now a hack is to pass it down to commands |
| 26 | // that declare their own. |
| 27 | PersistentPreRunE: persistentPreRunE, |
| 28 | PersistentPostRunE: ensureGlobalEnvEnabled, |
| 29 | } |
| 30 | |
| 31 | addCommandAndHideConfigFlag(globalCmd, addCmd()) |
| 32 | addCommandAndHideConfigFlag(globalCmd, installCmd()) |
| 33 | addCommandAndHideConfigFlag(globalCmd, pathCmd()) |
| 34 | addCommandAndHideConfigFlag(globalCmd, pullCmd()) |
| 35 | addCommandAndHideConfigFlag(globalCmd, pushCmd()) |
| 36 | addCommandAndHideConfigFlag(globalCmd, removeCmd()) |
| 37 | addCommandAndHideConfigFlag(globalCmd, runCmd(runFlagDefaults{ |
| 38 | omitNixEnv: true, |
| 39 | })) |
| 40 | addCommandAndHideConfigFlag(globalCmd, servicesCmd(persistentPreRunE)) |
| 41 | addCommandAndHideConfigFlag(globalCmd, shellEnvCmd(shellenvFlagDefaults{ |
| 42 | omitNixEnv: true, |
| 43 | })) |
| 44 | addCommandAndHideConfigFlag(globalCmd, updateCmd()) |
| 45 | addCommandAndHideConfigFlag(globalCmd, listCmd()) |
| 46 | |
| 47 | return globalCmd |
| 48 | } |
| 49 | |
| 50 | func addCommandAndHideConfigFlag(parent, child *cobra.Command) { |
| 51 | parent.AddCommand(child) |
no test coverage detected