Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

should not be allowed flags for subcommand before the subcommand itself on the command line #167

Closed
sio4 opened this issue Jun 6, 2022 · 1 comment · Fixed by #168
Closed
Assignees
Labels
bug Something isn't working

Comments

@sio4
Copy link
Member

sio4 commented Jun 6, 2022

Currently, the behavior of the buffalo CLI allows putting flags for the subcommand before the subcommand itself, and as a result, they are sometimes interpreted in unexpected ways:

For example, buffalo pop reset -e test is the proper way to run the subcommand pop with arguments reset -e test. The current version of the buffalo command also allows running the same job with the command line buffalo -e test pop reset, and in this case, the subcommand and arguments for the subcommand are interpreted as the same as the desired command line above. However, if the command line is changed slightly, e.g. buffalo -d -e test pop reset, the command line is interpreted as subcommand test with the argument for the subcommand -d -e pop reset

  • buffalo pop reset -e test - standard usage: as pop with args reset -e test
  • buffalo -e test pop reset - allowed currently: as pop with args -e test reset
  • buffalo -e test pop reset -d - also works fine: as pop with args -e test reset -d
  • buffalo -d -e test pop reset - does not work: become test with args -d -e pop reset
  • buffalo -e test -d pop reset - does not work: become reset with args -e test -d pop

To make it clear, the command line should be a form of:

buffalo [global flags...] subcommand [flags for subcommand]

and we should not allow mixed positions. (by the way, currently, there is no global flag except autogenerated --help.)

@sio4 sio4 added the bug Something isn't working label Jun 6, 2022
@sio4 sio4 self-assigned this Jun 6, 2022
@sio4
Copy link
Member Author

sio4 commented Jun 6, 2022

some outputs for reference:

$ buffalo -d -e test pop reset
[POP] 2022/06/04 19:39:36 info - dropped database hc_uart_test
[POP] 2022/06/04 19:39:36 info - created database hc_uart_test
[POP] 2022/06/04 19:39:36 info - loaded schema for hc_uart_test
INFO[0000] go test -p 1 -tags development -d -e pop reset
no Go files in /home/sio4/git/hyeoncheon/uart
Usage:
  buffalo test [flags]

Flags:
  -h, --help   help for test

ERRO[0000] Error: exit status 1
$ buffalo -e test -d pop reset
ERRO[0000] Error: unknown command "reset" for "buffalo"

Did you mean this?
        test

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant