<div dir="ltr"><div>After gathering some initial user stories[0] and feedback from Pulp users[1], the Pulp CLI mini-team[2] has been exploring implementation options. In doing so, we've spent a few days creating a prototype that we'd like the Pulp community to review and test. This proof of concept is available at the following repository:</div><div><br></div><div><a href="https://github.com/werwty/pulpcli-POC/">https://github.com/werwty/pulpcli-POC/</a></div><div><br></div><div>This PoC provides an autogenerated set of commands for each endpoint available by the REST API schema. Having an autogenerated CLI means it automatically supports all plugins and provides complete feature parity with our REST API. </div><div><br></div><div>Another highlight of the PoC's design is that it's easy to extend. One of the feedback items we got from pulp users is that they use scripts to automate their usage of the CLI, while other teams like RHUI have their own CLI. With this PoC design, users will be able to write their own custom commands and functionality in Python. This will also allow us (the Pulp team) to provide more complex commands and workflows in the future too.</div><div><br></div><div><br></div><div>Installation/Usage</div><div>==============</div><div><br></div><div>To see information about how to install and use the PoC CLI, check out the README:</div><div><br></div><div><a href="https://github.com/werwty/pulpcli-POC/#installation">https://github.com/werwty/pulpcli-POC/#installation</a></div><div><br></div><div><br></div><div>Features</div><div>=======</div><div><br></div><div>- Auto-generated CLI commands with one command for each API endpoint</div><div>- Support for plugins</div><div>- Pagination support</div><div>- Lookup via resource UUIDs or names</div><div>- Help screens</div><div>- Task polling</div><div>- Autocompletion for commands and arguments</div><div>- Extensibility</div><div>  - Support in the future to create our own complex commands/workflows</div><div>  - Users/plugin writers can create their own commands and ship their own cli plugins</div><div><br></div><div><br></div><div>Implementation</div><div>===========</div><div><br></div><div>We first began by exploring pre-existing solutions like openapi-cli-client and coreapi-cli. The former, openapli-cli-client, was unmaintained and didn't seem to work with our API. The coreapi-cli package seemed promising but we found it hard to extend and it lacked some of the features we wanted to support in our initial set of user stories (e.g. pagination, task polling, etc). We realized that it was a rather small codebase that merely integrated the coreapi python package[3] with the cli package, click[4].</div><div><br></div><div>So next we began investigating writing our own CLI using coreapi and click. Doing so was easy and it only required a few lines of code. We were then able to add on more features like task polling with little effort. We also explored using an alternative to click called argparse[5] but found it very hard to work with.</div><div><br></div><div><br></div><div>Next Steps</div><div>========</div><div><br></div><div>We first want to get feedback on this PoC. If we decide to move forward with it, there are a few things we'd like to do to prepare this CLI for an MVP:</div><div><br></div><div>- Provide docs for how to extend the CLI and write custom commands</div><div>- Better error handling</div><div>- Fix resource lookup for master/detail routes</div><div>- Progress reporting when polling tasks</div><div>- Support for file uploads</div><div>- Authentication and configuration</div><div>- Format of responses</div><div>- Swich out coreapi for openapi</div><div><br></div><div>All CLI-related tasks will be tracked through this redmine Epic: <a href="https://pulp.plan.io/issues/3756">https://pulp.plan.io/issues/3756</a></div><div><br></div><div>Before we proceed though, we'd like to get feedback. So please review and test out our PoC. Let us know if you have any comments and suggestions.</div><div><br></div><div>[0] <a href="https://www.redhat.com/archives/pulp-dev/2018-May/msg00004.html">https://www.redhat.com/archives/pulp-dev/2018-May/msg00004.html</a></div><div>[1] <a href="https://www.redhat.com/archives/pulp-list/2018-May/msg00007.html">https://www.redhat.com/archives/pulp-list/2018-May/msg00007.html</a></div><div>[2] asmacdo, bizhang, daviddavis, dawalker, and dkliban</div><div>[3] <a href="https://github.com/core-api/python-client">https://github.com/core-api/python-client</a></div><div>[4] <a href="http://click.pocoo.org/5/">http://click.pocoo.org/5/</a></div><div>[5] <a href="https://docs.python.org/3/library/argparse.html">https://docs.python.org/3/library/argparse.html</a></div><div><br></div></div>