Add cli and version.py
This commit is contained in:
parent
cde9a9056c
commit
cbb8180ff3
@ -1,8 +1,7 @@
|
||||
import sqlite3
|
||||
|
||||
from . import db
|
||||
|
||||
__version__ = "0.0.1"
|
||||
from .db import init
|
||||
from .version import __version__
|
||||
|
||||
|
||||
# Calling code will build up a large DAG then at the very last step, call
|
||||
@ -10,7 +9,7 @@ __version__ = "0.0.1"
|
||||
# data by asking the user for an output dir. However, we need a database
|
||||
# initialized in order to build up the DAG in the first place, so here we
|
||||
# initialize an in-memory database to use until we have an output directory.
|
||||
_conn = db.init(":memory:")
|
||||
_conn = init(":memory:")
|
||||
|
||||
|
||||
def save_data(
|
||||
|
||||
4
nancy/__main__.py
Normal file
4
nancy/__main__.py
Normal file
@ -0,0 +1,4 @@
|
||||
if __name__ == "__main__":
|
||||
from . import cli
|
||||
|
||||
cli.main()
|
||||
28
nancy/cli/__init__.py
Normal file
28
nancy/cli/__init__.py
Normal file
@ -0,0 +1,28 @@
|
||||
import click
|
||||
|
||||
from ..version import __version__
|
||||
|
||||
from .freeze import freeze, thaw
|
||||
|
||||
|
||||
# from https://click.palletsprojects.com/en/5.x/advanced/
|
||||
class AliasedGroup(click.Group):
|
||||
def get_command(self, ctx, cmd_name):
|
||||
rv = click.Group.get_command(self, ctx, cmd_name)
|
||||
if rv is not None:
|
||||
return rv
|
||||
matches = [x for x in self.list_commands(ctx) if x.startswith(cmd_name)]
|
||||
if not matches:
|
||||
return None
|
||||
elif len(matches) == 1:
|
||||
return click.Group.get_command(self, ctx, matches[0])
|
||||
ctx.fail("Too many matches: %s" % ", ".join(sorted(matches)))
|
||||
|
||||
|
||||
@click.group(f"nancy v{__version__}", cls=AliasedGroup)
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
main.add_command(freeze)
|
||||
main.add_command(thaw)
|
||||
13
nancy/cli/freeze.py
Normal file
13
nancy/cli/freeze.py
Normal file
@ -0,0 +1,13 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument("directory")
|
||||
def freeze(directory):
|
||||
pass
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument("files", nargs=-1) # , help="Files or directories to thaw.")
|
||||
def thaw(files):
|
||||
pass
|
||||
1
nancy/version.py
Normal file
1
nancy/version.py
Normal file
@ -0,0 +1 @@
|
||||
__version__ = "0.0.1pre"
|
||||
Loading…
x
Reference in New Issue
Block a user