bruceadams / wdscli

Command line interface to the IBM Watson Discovery Service API
MIT License
8 stars 0 forks source link

Enhance handling of defaults #7

Open bruceadams opened 7 years ago

bruceadams commented 7 years ago

Chatting with some people about wdscli as it stands helped get me thinking about how it might be made easier to use.

I'm fairly pleased with the current, stateless, implementation, but it does mean that credentials need to be supplied for every command. Also, for most commands, several service calls need to be made to establish context for whatever the command is going to do. That is: figuring out an environment_id, often a collection_id and sometimes a configuration_id. These service calls take time and can fail.

I can imagine wdscli having an option to write current defaults out to a file, then subsequent commands could use the defaults.

Suppose defaults are written to a file in the current directory. By using the current directory for defaults, a user can have different defaults for different contexts. Let's name that file wdscli-defaults.json wdscli could write out to that file: on request and probably whenever a resource is created. For example: creating a collection could set the defaults to: the current service credentials, the environment_id where the collection was created and the collection_id of that newly created collection. Then commands like show-environment, show-collection and add-document do not need any selection arguments.