devspace icon indicating copy to clipboard operation
devspace copied to clipboard

Improve CLI argument order

Open maikelvl opened this issue 2 years ago • 0 comments

Problem

Is your feature request related to a problem? Yes, usability. Most CLI tools have a more logical argument order. As you want to be efficient at the command line, the less to type the better.

Currently the argument order is like devspace <verb> <noun> [...]. This leads to a command like:

devspace list vars
devspace set var FOO=bar

After listing the variables you probably want to do something with it. Like setting one for example. In that way the following makes more sense and is more efficient when typing:

devspace vars list
devspace vars set FOO=bar

A few examples of other noun-verb CLI's:

  • gcloud (gcloud compute disks list, gcloud compute disks describe) After listing the disks you probably want to do something with it so it's logical to have the verb as last part.
  • terraform (terraform state list, terraform state show)
  • helm (helm dependency list, helm dependency build - it has both noun-verb and verb-noun)
  • docker (docker container ls, docker container inspect)

(some tools have a 'list' root command, but notice that doesn't have a noun subcommand)

However, there are other verb-noun CLI's as well:

  • kubectl In the context of Kubernetes the most variable part of the command - in my case - is the noun, which for Kubernetes is the resource. First look at the deployments (kubectl get deploy) and then look at the services (kubectl get svc) and in detail with added -o yaml (notice there is no list). This is more efficient because you can reuse your previous command and just edit the last part.

Current devspace argument tree:

devspace
├── list
│   ├── commands     Lists all custom DevSpace commands
│   ├── contexts     Lists all kube contexts
│   ├── deployments  Lists and shows the status of all deployments
│   ├── namespaces   Lists all namespaces in the current context
│   ├── plugins      Lists all installed devspace plugins
│   ├── ports        Lists port forwarding configurations
│   ├── profiles     Lists all DevSpace profiles
│   ├── sync         Lists sync configuration
│   └── vars         Lists the vars in the active config
├── set
│   └── var          Sets a variable
├── reset
│   ├── dependencies Resets the dependencies cache
│   ├── pods         Resets the replaced pods
│   └── vars         Resets the current config vars
├── add
│   └── plugin       Adds a plugin to devspace
├── remove
│   ├── context      Removes a kubectl-context
│   └── plugin       Removes a devspace plugin
├── update
│   └── plugin       Updates a devspace plugin
├── use
│   ├── context      Tells DevSpace which kube context to use
│   └── namespace    Tells DevSpace which namespace to use
├── cleanup
│   └── images       Deletes all locally created images from docker
.
.

Suggested solution

Reversed devspace argument tree:

devspace
├── commands
│   └── list         Lists all custom DevSpace commands
├── contexts
│   ├── remove       Removes a kubectl-context
│   ├── list         Lists all kube contexts
│   └── use          Tells DevSpace which kube context to use
├── deployments
│   └── list         Lists and shows the status of all deployments
├── namespace
│   ├── list         Lists all namespaces in the current context
│   └── use          Tells DevSpace which namespace to use
├── plugins
│   ├── list         Lists all installed devspace plugins
│   ├── add          Adds a plugin to devspace
│   ├── remove       Removes a devspace plugin
│   └── update       Updates a devspace plugin
├── ports
│   └── list         Lists port forwarding configurations
├── profiles
│   └── list         Lists all DevSpace profiles
├── sync
│   └── list         Lists sync configuration
├── vars
│   ├── list         Lists the vars in the active config
│   ├── set         Sets a variable
│   └── reset        Resets the current config vars
├── dependencies
│   └── reset        Resets the dependencies cache
├── images
│   └── cleanup      Deletes all locally created images from docker
├── pods
│   └── reset        Resets the replaced pods
.
.
+ the existing commands for backwards compatibility

I'm aware this would be a very radical change.

Which alternative solutions exist?

None

Additional context

/kind feature

maikelvl avatar May 05 '22 20:05 maikelvl