Skip to content

Commit

Permalink
Don't support rm verb in cli commands anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanjli committed Dec 27, 2024
1 parent 9ca632c commit 1b02be5
Show file tree
Hide file tree
Showing 20 changed files with 122 additions and 133 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- (Breaking change; cli) The verbs `rm` and `remove` have been deleted from all commands (e.g. `forklift pallet rm`), because the two-character verb `rm` doesn't line up nicely with the three-character verb `add`; `del` or `delete` should be used instead (e.g. `forklift pallet del`).

### Fixed

- (cli) Git progress log messages are now printed to stderr instead of stdout.
Expand Down
16 changes: 8 additions & 8 deletions cmd/forklift/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,28 @@ func getRepoCache(wpath string, ensureWorkspace bool) (*forklift.FSRepoCache, er
return cache, nil
}

// rm-all
// del-all

func rmAllAction(c *cli.Context) error {
if err := rmGitRepoAction("mirror", getMirrorCache)(c); err != nil {
func delAllAction(c *cli.Context) error {
if err := delGitRepoAction("mirror", getMirrorCache)(c); err != nil {
return errors.Wrap(err, "couldn't remove cached mirrors")
}
if err := rmGitRepoAction("pallet", getPalletCache)(c); err != nil {
if err := delGitRepoAction("pallet", getPalletCache)(c); err != nil {
return errors.Wrap(err, "couldn't remove cached pallets")
}
if err := rmGitRepoAction("repo", getRepoCache)(c); err != nil {
if err := delGitRepoAction("repo", getRepoCache)(c); err != nil {
return errors.Wrap(err, "couldn't remove cached repositories")
}

if err := rmImgAction(c); err != nil {
if err := delImgAction(c); err != nil {
return errors.Wrap(err, "couldn't remove unused Docker container images")
}
return nil
}

// rm-img
// del-img

func rmImgAction(_ *cli.Context) error {
func delImgAction(_ *cli.Context) error {
fmt.Fprintln(os.Stderr, "Removing unused Docker container images...")
client, err := docker.NewClient()
if err != nil {
Expand Down
36 changes: 18 additions & 18 deletions cmd/forklift/cache/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,49 +95,49 @@ var Cmd = &cli.Command{
Action: addGitRepoAction(getRepoCache),
},
{
Name: "rm-all",
Aliases: []string{"remove-all", "del-all", "delete-all"},
Name: "del-all",
Aliases: []string{"delete-all"},
Category: "Modify the cache",
Usage: "Removes all cached resources",
Action: rmAllAction,
Action: delAllAction,
},
{
Name: "rm-mir",
Aliases: []string{"remove-mirrors", "del-mir", "delete-mirrors"},
Name: "del-mir",
Aliases: []string{"delete-mirrors"},
Category: "Modify the cache",
Usage: "Removes local mirrors of git repositories",
// TODO: allow only removing mirrors matching a glob pattern
Action: rmGitRepoAction("mirror", getMirrorCache),
Action: delGitRepoAction("mirror", getMirrorCache),
},
{
Name: "rm-plt",
Aliases: []string{"remove-pallets", "del-plt", "delete-pallets"},
Name: "del-plt",
Aliases: []string{"delete-pallets"},
Category: "Modify the cache",
Usage: "Removes locally-cached pallets",
// TODO: allow only removing pallets matching a glob pattern
Action: rmGitRepoAction("pallet", getPalletCache),
Action: delGitRepoAction("pallet", getPalletCache),
},
{
Name: "rm-repo",
Aliases: []string{"remove-repositories", "del-repo", "delete-repositories"},
Name: "del-repo",
Aliases: []string{"delete-repositories"},
Category: "Modify the cache",
Usage: "Removes locally-cached repos",
// TODO: allow only removing repos matching a glob pattern
Action: rmGitRepoAction("repo", getRepoCache),
Action: delGitRepoAction("repo", getRepoCache),
},
{
Name: "rm-dl",
Aliases: []string{"remove-downloads", "del-dl", "delete-downloads"},
Name: "del-dl",
Aliases: []string{"delete-downloads"},
Category: "Modify the cache",
Usage: "Removes locally-cached file downloads",
Action: rmDlAction,
Action: delDlAction,
},
{
Name: "rm-img",
Aliases: []string{"remove-images", "del-img", "delete-images"},
Name: "del-img",
Aliases: []string{"delete-images"},
Category: "Modify the cache",
Usage: "Removes unused Docker container images",
Action: rmImgAction,
Action: delImgAction,
},
},
}
4 changes: 2 additions & 2 deletions cmd/forklift/cache/downloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func lsDlAction(c *cli.Context) error {
return nil
}

// rm-dl
// del-dl

func rmDlAction(c *cli.Context) error {
func delDlAction(c *cli.Context) error {
workspace, err := forklift.LoadWorkspace(c.String("workspace"))
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/forklift/cache/git-repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ type remover interface {
Remove() error
}

// rm-*
// del-*

func rmGitRepoAction[Cache remover](
func delGitRepoAction[Cache remover](
gitRepoType string, cacheGetter func(wpath string, ensureWorkspace bool) (Cache, error),
) func(c *cli.Context) error {
return func(c *cli.Context) error {
Expand Down
44 changes: 18 additions & 26 deletions cmd/forklift/dev/plt/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ func makeModifySubcmds(versions Versions) []*cli.Command {
return slices.Concat(
makeModifyFileSubcmds(),
makeModifyPltSubcmds(versions),
// TODO: add `add-imp`, `rm-imp`, `set-imp-disabled`, `unset-imp-disabled`,
// `add-imp-mod`, and `rm-imp-mod` subcommands
// TODO: add `add-imp`, `del-imp`, `set-imp-disabled`, `unset-imp-disabled`,
// `add-imp-mod`, and `del-imp-mod` subcommands
makeModifyRepoSubcmds(versions),
makeModifyDeplSubcmds(versions),
)
Expand All @@ -473,18 +473,18 @@ func makeModifyFileSubcmds() []*cli.Command {
},
},
{
Name: "rm-file",
Aliases: []string{"remove-file", "del-file", "delete-file"},
Name: "del-file",
Aliases: []string{"delete-file"},
Category: category,
Usage: "Removes the specified file in the development pallet",
ArgsUsage: "file_path",
Action: rmFileAction,
Action: delFileAction,
},
}
}

func makeModifyPltSubcmds(versions Versions) []*cli.Command {
const category = "Modify the pallet's pallet requirements"
const category = "Modify the pallet's requirements"
return []*cli.Command{
{
Name: "add-plt",
Expand All @@ -511,10 +511,9 @@ func makeModifyPltSubcmds(versions Versions) []*cli.Command {
// TODO: add a show-upgrade-plt-query plt_path[@] command
// TODO: add a set-upgrade-plt-query plt_path@version_query command
{
Name: "rm-plt",
Name: "del-plt",
Aliases: []string{
"remove-pallet", "remove-pallets",
"del-plt", "delete-pallet", "delete-pallets",
"delete-pallet", "delete-pallets",
"drop-plt", "drop-pallet", "drop-pallets",
},
Category: category,
Expand All @@ -527,13 +526,13 @@ func makeModifyPltSubcmds(versions Versions) []*cli.Command {
"depend on them",
},
},
Action: rmPltAction(versions),
Action: delPltAction(versions),
},
}
}

func makeModifyRepoSubcmds(versions Versions) []*cli.Command {
const category = "Modify the pallet's package repository requirements"
const category = "Modify the pallet's requirements"
return []*cli.Command{
{
Name: "add-repo",
Expand All @@ -560,10 +559,9 @@ func makeModifyRepoSubcmds(versions Versions) []*cli.Command {
// TODO: add a set-upgrade-repo-query repo_path@version_query command
},
{
Name: "rm-repo",
Name: "del-repo",
Aliases: []string{
"remove-repository", "remove-repositories",
"del-repo", "delete-repository", "delete-repositories",
"delete-repository", "delete-repositories",
"drop-repo", "drop-repository", "drop-repositories",
},
Category: category,
Expand All @@ -576,7 +574,7 @@ func makeModifyRepoSubcmds(versions Versions) []*cli.Command {
"depend on them",
},
},
Action: rmRepoAction(versions),
Action: delRepoAction(versions),
},
}
}
Expand Down Expand Up @@ -629,16 +627,13 @@ func makeModifyDeplSubcmds( //nolint:funlen // this is already decomposed; it's
Action: addDeplAction(versions),
},
{
Name: "rm-depl",
Aliases: []string{
"remove-deployment", "remove-deployments",
"del-depl", "delete-deployment", "delete-deployments",
},
Name: "del-depl",
Aliases: []string{"delete-deployment", "delete-deployments"},
Category: category,
Usage: "Removes deployment from the pallet",
ArgsUsage: "deployment_name...",
Flags: baseFlags,
Action: rmDeplAction(versions),
Action: delDeplAction(versions),
},
{
Name: "set-depl-pkg",
Expand Down Expand Up @@ -683,11 +678,8 @@ func makeModifyDeplSubcmds( //nolint:funlen // this is already decomposed; it's
Action: addDeplFeatAction(versions),
},
{
Name: "rm-depl-feat",
Name: "del-depl-feat",
Aliases: []string{
"remove-deployment-feature",
"remove-deployment-features",
"del-depl-feat",
"delete-deployment-feature",
"delete-deployment-features",
"disable-depl-feat",
Expand All @@ -698,7 +690,7 @@ func makeModifyDeplSubcmds( //nolint:funlen // this is already decomposed; it's
Usage: "Disables the specified package features in the specified deployment",
ArgsUsage: "deployment_name feature_name...",
Flags: baseFlags,
Action: rmDeplFeatAction(versions),
Action: delDeplFeatAction(versions),
},
{
Name: "set-depl-disabled",
Expand Down
8 changes: 4 additions & 4 deletions cmd/forklift/dev/plt/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ func addDeplAction(versions Versions) cli.ActionFunc {
}
}

// rm-depl
// del-depl

func rmDeplAction(versions Versions) cli.ActionFunc {
func delDeplAction(versions Versions) cli.ActionFunc {
return func(c *cli.Context) error {
plt, caches, err := processFullBaseArgs(c, processingOptions{
requirePalletCache: true,
Expand Down Expand Up @@ -206,9 +206,9 @@ func addDeplFeatAction(versions Versions) cli.ActionFunc {
}
}

// rm-depl-feat
// del-depl-feat

func rmDeplFeatAction(versions Versions) cli.ActionFunc {
func delDeplFeatAction(versions Versions) cli.ActionFunc {
return func(c *cli.Context) error {
plt, caches, err := processFullBaseArgs(c, processingOptions{
requirePalletCache: true,
Expand Down
4 changes: 2 additions & 2 deletions cmd/forklift/dev/plt/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func editFileAction(c *cli.Context) error {
return fcli.EditFileWithCOW(plt, c.Args().First(), c.String("editor"))
}

// rm-file
// del-file

func rmFileAction(c *cli.Context) error {
func delFileAction(c *cli.Context) error {
plt, _, err := processFullBaseArgs(c, processingOptions{
enableOverrides: true,
merge: true,
Expand Down
4 changes: 2 additions & 2 deletions cmd/forklift/dev/plt/pallets.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,9 @@ func addPltAction(versions Versions) cli.ActionFunc {
}
}

// rm-plt
// del-plt

func rmPltAction(versions Versions) cli.ActionFunc {
func delPltAction(versions Versions) cli.ActionFunc {
return func(c *cli.Context) error {
plt, err := getShallowPallet(c.String("cwd"))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/forklift/dev/plt/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ func addRepoAction(versions Versions) cli.ActionFunc {
}
}

// rm-repo
// del-repo

func rmRepoAction(versions Versions) cli.ActionFunc {
func delRepoAction(versions Versions) cli.ActionFunc {
return func(c *cli.Context) error {
plt, _, err := processFullBaseArgs(c, processingOptions{
enableOverrides: true,
Expand Down
6 changes: 3 additions & 3 deletions cmd/forklift/host/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ var Cmd = &cli.Command{
Action: lsConAction,
},
{
Name: "rm",
Aliases: []string{"remove", "del", "delete"},
Name: "del",
Aliases: []string{"delete"},
Category: "Modify the Docker host",
Usage: "Removes all Docker Compose applications",
Action: rmAction,
Action: delAction,
},
},
}
4 changes: 2 additions & 2 deletions cmd/forklift/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func lsConAction(c *cli.Context) error {
return nil
}

// rm
// del

func rmAction(c *cli.Context) error {
func delAction(c *cli.Context) error {
client, err := docker.NewClient()
if err != nil {
return errors.Wrap(err, "couldn't make Docker API client")
Expand Down
Loading

0 comments on commit 1b02be5

Please sign in to comment.