You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

64 lines
1.7 KiB

#!/usr/bin/env python3
import click
# TODO: replace with plugin manager
from database import database
from automate import automate
from reqbt import reqbt
from graphs import graphs
from convert import convert
_commands = [
database,
automate,
reqbt,
graphs,
convert
]
# main-entry point to the entire command-line interface
@click.group()
@click.option('-v', '--verbose',
help='Print additional information.',
is_flag=True)
@click.option('--data_dir',
help='Set the application data directory.',
type=click.Path(),
default='.app')
@click.option('--resource_dir',
help='Set the resource data directory.',
type=click.Path(),
default='resources')
@click.pass_context
def cli(ctx, data_dir, resource_dir, verbose):
"""
A command-line interface wrapper to the Criminal Justice Software toolchain.\f
Args:
ctx: Click command-line interface context.
verbose: Flag to enable additional prints.
database: Path to a SQLite3 database.
"""
ctx.ensure_object(dict)
# determine project working directory
project_dir = '/home/csguest/Desktop/cjs2/cjs' # '/home/dev/cjs2/cjs'
project_path = lambda path: '%s/%s' % (project_dir, path)
# initialize context object
# store non-click information
# TODO: replace hard coded path with a more cross-platform method
ctx.obj['data_dir'] = project_path(data_dir)
ctx.obj['resource_dir'] = project_path(resource_dir)
# store click-related information
# global flags
ctx.obj['verbose'] = verbose
# load external modules into cli
for cmd in _commands:
cli.add_command(cmd)
if __name__ == '__main__':
cli()