This repository seeks to evaluate different first- and third-party options for creating command-line interfaces (CLIs) with Go.
In each sub-directory, a CLI is created with the same interface spec (based on and reduced from another repo of mine, oc-inspector). This spec requires the CLI to have the following commands (verbs) on the following object types (nouns):
- list
- pods
- deployments
- services
- nodes
- events
- describe
- pods
- deployments
- services
- nodes
- diff
- pods
- deployments
- services
The CLI library must be able to use these verb-noun contexts (VNCs) to enforce option tpying, use default values for applicable options, and determine which passed options are valid (or invalid), required, excluded, dependent on one-another, and which combinations are mutually exclusive.
The following options should be evaluated correctly:
These options should always be valid
--verbose, -v
bool
Turning on verbose output to provide more fine-grained tracing
--namespace, -n
string
Limit interaction with the cluster to just the passed namespace
--timeout, --request-timeout
time.Duration
The timeout for any given request to the cluster
--global-timeout
time.Duration
The timeout for all of the work the program is requested to do
--output, -o
enum: (table, json, yaml)
Structures the output so it can be more easily consumed by the caller
These options should be available to all calls to the verb they are listed under, no matter which noun is called
These options should be valid whenever the list verb is used
--filter
--sort-by
--watch, -w
--wide
These options are only valid only for the noun they are listed under when calling the list verb
--phase
--node
--restarts-gt
--unavailable
--min-replicas
--type
--node
--not-ready
--type
--since
--filter
--name
--show-events
--show-containers
--show-logs
--show-replicas
--show-pods
--show-endpoints
--show-selectors
--show-pods
--show-capacity
--file, -f
--name
--ignore-metadata
--ignore-image-tag
--container
--ignore-replicas
--ignore-strategy
--ignore-cluster-ip
--ignore-node-port
In addition to actually being able to implement the above interface requirements, it
verb: The first positional argument after the name of the CLI binary. Indicates what the caller is trying to do.
e.g.:
$ dnf install golang
^^^^^^^
verb$ ocm get pods
^^^
verbnoun: The second positional argument, found immediately after the verb. Indicates the type of domain object that the caller is attepting to verb.
e.g.:
$ dnf install golang
^^^^^^
noun$ ocm get pods
^^^
nounVNC - The verb/noun context. This context dictates which command options are valid or invalid. Some combinations of verb + noun are
caller - The entity that invoked the CLI program. This may be a user manually entering commands into a terminal, or a computer
The ability of the options parser to be aware of required options for a given VNC.
If one option is defined, another option becomes valid or required
The ability for the options parser to determine if options are valid for the given verb/noun context.
The ability for the options parser to determine if two or more passed options conflict with one another.