diff --git a/nancy/__init__.py b/nancy/__init__.py index 4551337..e13c4f6 100644 --- a/nancy/__init__.py +++ b/nancy/__init__.py @@ -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( diff --git a/nancy/__main__.py b/nancy/__main__.py new file mode 100644 index 0000000..42a62f5 --- /dev/null +++ b/nancy/__main__.py @@ -0,0 +1,4 @@ +if __name__ == "__main__": + from . import cli + + cli.main() diff --git a/nancy/cli/__init__.py b/nancy/cli/__init__.py new file mode 100644 index 0000000..87b5313 --- /dev/null +++ b/nancy/cli/__init__.py @@ -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) diff --git a/nancy/cli/freeze.py b/nancy/cli/freeze.py new file mode 100644 index 0000000..41e530b --- /dev/null +++ b/nancy/cli/freeze.py @@ -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 diff --git a/nancy/version.py b/nancy/version.py new file mode 100644 index 0000000..0a2dcf8 --- /dev/null +++ b/nancy/version.py @@ -0,0 +1 @@ +__version__ = "0.0.1pre"