Closed JnyJny closed 2 years ago
Addresses #9
Checking my understanding here... By getting rid of the stand alone command-line option extract
that means people will have to extract an already downloaded bite using some other tool, correct?
That's true, however most operating systems ship with a zip archive utility; typically called zip/unzip. What are the scenarios where you would want a stand-alone extract command?
The first two can be solved with git checkout -- <bite>
if the bite was checked in (something we can automate) or by removing the bite directory and re-downloading the bite.
I think having download check for the existence of a zip archive before trying to download would solve the extract problem. We could cache zips in a directory of the repo to speed up that operation (and making keep_zip=True the default behavior).
My thought was I like the tool being able to deal with all things bite related. If someone has a bite already downloaded, they could extract it using the tool. But maybe I'm holding just holding on to original original workflow that this was designed to improve.
I think having download check for the existence of a zip archive before trying to download would solve the extract problem. We could cache zips in a directory of the repo to speed up that operation (and making keep_zip=True the default behavior).
I like that idea. Should I merge this pull first or hold off?
I would say merge this PR (of course I would) since it provides a scaffold for the rest of the work (caching).
Haha! You would to merge the pull request you made? That is odd.
Download changed:
Submit changed:
Removed the standalone extract command-line option.
Download operation now:
These changes required re-organizing the
__main__.py
functions, specifically breaking out all the option processing in themain()
function into their own specific subcommands.The
global_options
function is a typer callback that is invoked before any of the other subcommand decorated functions, making it a good place to take care of global options that are used by the subcommands. In this particular case, it's the credentials for PyBites obtained from the environment. The credentials are passed to subcommands via thetyper.Context
automatic argument, specifically thectx.obj
attribute which can be any object. I created anamedtuple
calledGlobalOptions
with a single membercreds
which is a tuple of username and password strings.While the user must type a little more, e.g.
download
vs-d
, the code is much simplier and it will be easier to extend this utility when new functionality is identified.