CCI-MOC / hil

Hardware Isolation Layer, formerly Hardware as a Service
Apache License 2.0
24 stars 54 forks source link

Make CLI pretty #1051

Closed naved001 closed 5 years ago

naved001 commented 5 years ago

Credit to @RobinKaul for doing all this work. The original PR #1040 has some messed up commit history, so I am starting a new one.

In the next few commits I'll address @zenhack and @ianballou's comments (and mine too).

zenhack commented 5 years ago

Might be a little slow getting to this one (and probably generally less responsive this week); I blocked off a fair chunk of time to work on other projects this week.

naved001 commented 5 years ago

Just want to finish this quickly since a lot of people have been asking for a good interface. Question for reviewers (@zenhack @ianballou)

  1. The flag to print json output is --jsonout, I want to use --json but I can't because we import json. What's the best way to accomplish this? (I could just import json as something else, but not sure if it's pythonic or not).
  2. Should I update the output of other commands right here or would that make the review process difficult?
ianballou commented 5 years ago

My opinions: 1) Does the flag text string really need to be the same as the variable name? I feel like regardless of whether or not we import json as json shouldn't affect the strings we use for cli flags. 2) I think we should push what we have first and then make another PR.

ianballou commented 5 years ago

Adding to (1): There is a way to have a different variable name from the CLI flag string. Essentially you exploit the fact that Click will prioritize using arguments without dashes. The variable name follows whatever argument you put in the decorator that doesn't have --, but you can still use --json along with the dash-less one. Here's a link that shows this in more detail: https://stackoverflow.com/a/35574063

naved001 commented 5 years ago

@ianballou thanks for 1. Figured it out now.

ianballou commented 5 years ago

I'm pretty sure I'm all good with this, I'll give a thumbs up when the json jsonout bit is changed

naved001 commented 5 years ago

I'm pretty sure I'm all good with this, I'll give a thumbs up when the json jsonout bit is changed

okay, done.

zenhack commented 5 years ago

LGTM