cmd/list, doc, test/system: Add 'ls' as an alias for 'list' - #1837
cmd/list, doc, test/system: Add 'ls' as an alias for 'list'#1837NewtonChutney wants to merge 1 commit into
Conversation
Many users are used to typing 'ls' from everyday Unix usage and expect it to work as a shorthand for listing things. Add 'ls' as an alias for the 'toolbox list' command, using Cobra's built-in Aliases mechanism so that flags, shell completion and error handling all keep working exactly as they do for 'list'. Fixes: containers#1836 containers#1837
654b65f to
9676560
Compare
Many users are used to typing 'ls' from everyday Unix usage and expect it to work as a shorthand for listing things. Add 'ls' as an alias for the 'toolbox list' command, using Cobra's built-in Aliases mechanism so that flags, shell completion and error handling all keep working exactly as they do for 'list'. Fixes: containers#1836 containers#1837
9676560 to
e605b0e
Compare
debarshiray
left a comment
There was a problem hiding this comment.
Thanks for working on this, @NewtonChutney ! I have been thinking about this myself, because ls(1) is such a common command, and podman image ls is an alias to podman image list and podman images.
At first glance, the code changes look good to me.
Could you please correct your Git authorship information with your full name and a real email address? For what it's worth, projects as diverse as GCC, GnuPG, Linux, Moby and Podman don't allow anonymous or pseudonymous contributions.
|
|
||
| var listCmd = &cobra.Command{ | ||
| Use: "list", | ||
| Aliases: []string{"ls"}, |
There was a problem hiding this comment.
The ls alias is not expected to show up in the shell completion, right? ie., toolbox l<TAB><TAB> will result in toolbox list . If so, then perfect, because it would be slightly annoying to choose between list and ls.
I am always nervous when looking at the shell completions because of the complex machinery involved.
There was a problem hiding this comment.
Ahh, let me test and confirm. And if ls does show up, if it is similar to how podman image ls is an auto completion, it shouldn't be an issue?
And I think I corrected my authorship? Lemme verify
There was a problem hiding this comment.
As far as I can make out, podman image l<TAB><TAB> includes only list, not ls.
There was a problem hiding this comment.
Ahh.. Okay then
So, it's with other tools and short flags that there's a shortcut
|
|
||
| ## NAME | ||
| toolbox\-list - List existing Toolbx containers and images | ||
| toolbox\-list, toolbox\-ls - List existing Toolbx containers and images |
There was a problem hiding this comment.
I wouldn't add toolbox-ls here. There's limited space here in the NAME section because it's supposed to have a brief one-line description. If a command has a longer name or has more aliases, then it won't fit. eg., the manual for podman image ls doesn't include the alias here.
We need to find a way to make this work:
$ man toolbox-lsOne way of doing that is to use the .so request like Podman does.
Summary
Adds
lsas an alias for thetoolbox listcommand, since many usersreach for
lsout of habit from everyday Unix usage.src/cmd/list.go: addlstolistCmd.Aliases(Cobra's built-inalias mechanism), so flags (
--containers/-c,--images/-i),error handling and shell completion (
GenBashCompletionV2,GenFishCompletion,GenZshCompletion) all keep working exactly asthey do for
list, with no other code changes needed.doc/toolbox-list.1.md,doc/toolbox.1.md: document the alias.test/system/102-list.bats,test/system/002-help.bats: add smokeand unknown-flag tests for
toolbox ls, mirroring existinglisttests.
Fixes #1836