Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: report error if arguments are given for subcommands that require no arguments #205

Merged
merged 1 commit into from
Mar 3, 2022

Conversation

k1LoW
Copy link
Contributor

@k1LoW k1LoW commented Mar 3, 2022

I use Colima conveniently every day. Thank you.

When I have multiple profiles, I have deleted the environment several times by running the following command by mistake.

$ colima list
PROFILE    STATUS     ARCH       CPUS    MEMORY    DISK
default    Running    aarch64    8       8GiB      128GiB
x64        Running    x86_64     8       8GiB      128GiB
$ # I want to delete `x64` profile !!
$ colima delete x64 # !!!???
are you sure you want to delete colima and all settings? [y/N] y
INFO[0015] deleting colima
INFO[0015] deleting ...                                  context=docker
INFO[0015] deleting ...                                  context=vm
INFO[0015] done
$ colima list 
PROFILE    STATUS     ARCH      CPUS    MEMORY    DISK
x64        Running    x86_64    8       8GiB      128GiB
$ # Oh. I missed.

This pull request is a fix to make error if arguments are given for subcommands that require no arguments.

$ make build
GOOS=darwin GOARCH=arm64 OS=Darwin ARCH=arm64 sh scripts/build.sh
++ git describe --tags --always
+ VERSION=v0.1.10-121-g853634a
++ git rev-parse HEAD
+ REVISION=853634a97fcdb97d8827dc18626002341f11df98
+ PACKAGE=github.com/abiosoft/colima/config
+ OUTPUT_DIR=_output/binaries
+ mkdir -p _output/binaries
+ OUTPUT_BIN=colima-Darwin-arm64
+ go build -ldflags '-X github.com/abiosoft/colima/config.appVersion=v0.1.10-121-g853634a -X github.com/abiosoft/colima/config.revision=853634a97fcdb97d8827dc18626002341f11df98' -o _outp
ut/binaries/colima-Darwin-arm64 ./cmd/colima
+ SHA256SUM=sha256sum
+ [[ darwin21 == \d\a\r\w\i\n* ]]
+ SHA256SUM='shasum -a 256'
+ cd _output/binaries
+ shasum -a 256 colima-Darwin-arm64
$ ./_output/binaries/colima-Darwin-arm64 list
PROFILE    STATUS     ARCH       CPUS    MEMORY    DISK
default    Running    aarch64    8       8GiB      128GiB
x64        Running    x86_64     8       8GiB      128GiB
$ ./_output/binaries/colima-Darwin-arm64 delete x64
Error: unknown command "x64" for "colima delete"
Usage:
  colima delete [flags]

Flags:
  -f, --force   do not prompt for yes/no
  -h, --help    help for delete

Global Flags:
  -p, --profile string   profile name, for multiple instances (default "default")
      --verbose          enable verbose log

FATA[0000] unknown command "x64" for "colima delete"
$

@abiosoft
Copy link
Owner

abiosoft commented Mar 3, 2022

Yeah, thanks. I actually considered handling extra argument for start, stop and delete as the value for --profile.

It feels intuitive that a user would expect colima delete x86 to mean delete the x86 profile.

@abiosoft abiosoft changed the title Make error if arguments are given for subcommands that require no arguments. cli: report error if arguments are given for subcommands that require no arguments Mar 3, 2022
@abiosoft abiosoft merged commit 5085352 into abiosoft:main Mar 3, 2022
@k1LoW k1LoW deleted the noargs branch March 3, 2022 22:46
@k1LoW
Copy link
Contributor Author

k1LoW commented Mar 3, 2022

Thank you for merging!

I actually considered handling extra argument for start, stop and delete as the value for --profile.

Looks good to me 👍

@abiosoft
Copy link
Owner

abiosoft commented Mar 7, 2022

Thank you for merging!

I actually considered handling extra argument for start, stop and delete as the value for --profile.

Looks good to me 👍

@k1LoW this has been implemented as part of v0.3.4 release https://github.com/abiosoft/colima/releases/tag/v0.3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants