netfoundry / python-netfoundry

PyPi module "netfoundry"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

allow abbreviations in nfctl CLI

qrkourier opened this issue · comments

For example, when it's necessary to specify a type of thing to list you could accept a short form of the full, valid type as long as its unambiguous.

$ nfctl list net
# in lieu of
$ nfctl list networks

and

$ nfctl --network "ACME Network" list end
# in lieu of
$ nfctl --network "ACME Network" list endpoint

It may also be possible to support abbreviated, unambiguous sub-commands like

$ nfctl --network "ACME Network" create endpoint

If terminal tab completion is possible, then short versions like end are moot. Simply hit tab to auto complete it. That being said, if the fragment is enough to uniquely identify a term, then that's just as good.

But ... auto-complete doesn't work well for terms with common prefixes like these 3: services, service-policies, and service-edge-router-policies.

For those cases, using the first letter of each word is effective: s, sp, and serp respectively.

@Russell-Allen Yes, argument auto-completion is a feature of nfctl. It may be configured like this:

$ eval "$(register-python-argcomplete nfctl)"
# or
$ source <(register-python-argcomplete nfctl)

Auto-complete works for sub-commands and choices. Example of sub-command is list in nfctl list and choices are like endpoints in nfctl list endpoints.

I see what you mean about choices with that begin with a similar string of characters. I'll give some thought to the possibility of using acronyms. I think I can generate those choices without making things too complex.