Skip to content

Commit f8702cc

Browse files
authored
feat(cmd): use aliases (#109)
Signed-off-by: Christopher Haar <[email protected]>
1 parent d50289c commit f8702cc

File tree

2 files changed

+2
-45
lines changed

2 files changed

+2
-45
lines changed

cmd/diff/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ type cli struct {
5959
// order they're specified here. Keep them in alphabetical order.
6060

6161
// Subcommands.
62-
Comp CompCmd `cmd:"" help:"Show impact of composition changes on existing XRs."`
63-
Diff DeprecatedDiffCmd `cmd:"" help:"(Deprecated) Use 'xr' subcommand instead. See what changes will be made against a live cluster when a given Crossplane resource would be applied."`
64-
XR XRCmd `cmd:"" help:"See what changes will be made against a live cluster when a given Crossplane resource would be applied."`
62+
Comp CompCmd `cmd:"" help:"Show impact of composition changes on existing XRs."`
63+
XR XRCmd `aliases:"diff" cmd:"" help:"See what changes will be made against a live cluster when a given Crossplane resource would be applied."`
6564

6665
Version version.Cmd `cmd:"" help:"Print the client and server version information for the current context."`
6766

cmd/diff/xr.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License.
1717
package main
1818

1919
import (
20-
"fmt"
21-
2220
"github.com/alecthomas/kong"
2321
dp "github.com/crossplane-contrib/crossplane-diff/cmd/diff/diffprocessor"
2422
"k8s.io/client-go/rest"
@@ -104,46 +102,6 @@ func makeDefaultXRLoader(c *XRCmd) (ld.Loader, error) {
104102
return ld.NewCompositeLoader(c.Files)
105103
}
106104

107-
// DeprecatedDiffCmd represents the deprecated diff command for backward compatibility.
108-
type DeprecatedDiffCmd struct {
109-
XRCmd
110-
}
111-
112-
// Help returns help instructions for the deprecated diff command.
113-
func (c *DeprecatedDiffCmd) Help() string {
114-
return `
115-
This command is deprecated. Please use 'crossplane-diff xr' instead.
116-
117-
This command returns a diff of the in-cluster resources that would be modified if the provided Crossplane resources were applied.
118-
119-
Similar to kubectl diff, it requires Crossplane to be operating in the live cluster found in your kubeconfig.
120-
121-
Examples:
122-
# Deprecated usage (still works but will show warning)
123-
crossplane-diff diff xr.yaml
124-
125-
# Preferred usage
126-
crossplane-diff xr xr.yaml
127-
`
128-
}
129-
130-
// Run executes the deprecated diff command with a deprecation warning.
131-
func (c *DeprecatedDiffCmd) Run(k *kong.Context, log logging.Logger, appCtx *AppContext, proc dp.DiffProcessor, loader ld.Loader) error {
132-
if _, err := fmt.Fprintln(k.Stderr, "Warning: The 'diff' subcommand is deprecated. Please use 'xr' instead."); err != nil {
133-
return err
134-
}
135-
136-
if _, err := fmt.Fprintln(k.Stderr, "Example: crossplane-diff xr your-file.yaml"); err != nil {
137-
return err
138-
}
139-
140-
if _, err := fmt.Fprintln(k.Stderr); err != nil {
141-
return err
142-
}
143-
144-
return c.XRCmd.Run(k, log, appCtx, proc, loader)
145-
}
146-
147105
// Run executes the XR diff command.
148106
func (c *XRCmd) Run(k *kong.Context, log logging.Logger, appCtx *AppContext, proc dp.DiffProcessor, loader ld.Loader) error {
149107
// the rest config here is provided by a function in main.go that's only invoked for commands that request it

0 commit comments

Comments
 (0)