| 1 | From: Peymaneh <[email protected]> |
| 2 | Date: Mon, 2 Jan 2023 21:33:36 +0100 |
| 3 | Subject: Remove obsolote subcommands |
| 4 | |
| 5 | forwarded: not-needed |
| 6 | --- |
| 7 | cmd/commands.go | 76 +++++++++++---------------------------------------------- |
| 8 | 1 file changed, 14 insertions(+), 62 deletions(-) |
| 9 | |
| 10 | --- a/cmd/commands.go |
| 11 | +++ b/cmd/commands.go |
| 12 | @@ -405,51 +405,6 @@ |
| 13 | }, |
| 14 | }) |
| 15 | |
| 16 | - RegisterCommand(Command{ |
| 17 | - Name: "upgrade", |
| 18 | - Short: "Upgrade Caddy (EXPERIMENTAL)", |
| 19 | - Long: ` |
| 20 | -Downloads an updated Caddy binary with the same modules/plugins at the |
| 21 | -latest versions. EXPERIMENTAL: May be changed or removed. |
| 22 | -`, |
| 23 | - CobraFunc: func(cmd *cobra.Command) { |
| 24 | - cmd.Flags().BoolP("keep-backup", "k", false, "Keep the backed up binary, instead of deleting it") |
| 25 | - cmd.RunE = WrapCommandFuncForCobra(cmdUpgrade) |
| 26 | - }, |
| 27 | - }) |
| 28 | - |
| 29 | - RegisterCommand(Command{ |
| 30 | - Name: "add-package", |
| 31 | - Usage: "<package[@version]...>", |
| 32 | - Short: "Adds Caddy packages (EXPERIMENTAL)", |
| 33 | - Long: ` |
| 34 | -Downloads an updated Caddy binary with the specified packages (module/plugin) |
| 35 | -added, with an optional version specified (e.g., "package@version"). Retains |
| 36 | -existing packages. Returns an error if any of the specified packages are already |
| 37 | -included. EXPERIMENTAL: May be changed or removed. |
| 38 | -`, |
| 39 | - CobraFunc: func(cmd *cobra.Command) { |
| 40 | - cmd.Flags().BoolP("keep-backup", "k", false, "Keep the backed up binary, instead of deleting it") |
| 41 | - cmd.RunE = WrapCommandFuncForCobra(cmdAddPackage) |
| 42 | - }, |
| 43 | - }) |
| 44 | - |
| 45 | - RegisterCommand(Command{ |
| 46 | - Name: "remove-package", |
| 47 | - Func: cmdRemovePackage, |
| 48 | - Usage: "<packages...>", |
| 49 | - Short: "Removes Caddy packages (EXPERIMENTAL)", |
| 50 | - Long: ` |
| 51 | -Downloads an updated Caddy binaries without the specified packages (module/plugin). |
| 52 | -Returns an error if any of the packages are not included. |
| 53 | -EXPERIMENTAL: May be changed or removed. |
| 54 | -`, |
| 55 | - CobraFunc: func(cmd *cobra.Command) { |
| 56 | - cmd.Flags().BoolP("keep-backup", "k", false, "Keep the backed up binary, instead of deleting it") |
| 57 | - cmd.RunE = WrapCommandFuncForCobra(cmdRemovePackage) |
| 58 | - }, |
| 59 | - }) |
| 60 | - |
| 61 | defaultFactory.Use(func(rootCmd *cobra.Command) { |
| 62 | manpageCommand := Command{ |
| 63 | Name: "manpage", |
| 64 | --- a/cmd/commands_test.go |
| 65 | +++ b/cmd/commands_test.go |
| 66 | @@ -15,22 +15,22 @@ |
| 67 | t.Fatal("default factory failed to build") |
| 68 | } |
| 69 | |
| 70 | - // check that the default factory has 17 commands; it doesn't |
| 71 | + // check that the default factory has 14 commands; it doesn't |
| 72 | // include the commands registered through calls to init in |
| 73 | // other packages |
| 74 | cmds := Commands() |
| 75 | - if len(cmds) != 17 { |
| 76 | - t.Errorf("expected 17 commands, got %d", len(cmds)) |
| 77 | + if len(cmds) != 14 { |
| 78 | + t.Errorf("expected 14 commands, got %d", len(cmds)) |
| 79 | } |
| 80 | |
| 81 | commandNames := slices.Collect(maps.Keys(cmds)) |
| 82 | slices.Sort(commandNames) |
| 83 | |
| 84 | expectedCommandNames := []string{ |
| 85 | - "adapt", "add-package", "build-info", "completion", |
| 86 | + "adapt", "build-info", "completion", |
| 87 | "environ", "fmt", "list-modules", "manpage", |
| 88 | - "reload", "remove-package", "run", "start", |
| 89 | - "stop", "storage", "upgrade", "validate", "version", |
| 90 | + "reload", "run", "start", |
| 91 | + "stop", "storage", "validate", "version", |
| 92 | } |
| 93 | |
| 94 | if !reflect.DeepEqual(expectedCommandNames, commandNames) { |