From ffde82d2375c8afb942486c647c673ead823f509 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 12 Feb 2016 22:19:08 -0500 Subject: [PATCH] Cleanup the CLI --- records.py | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/records.py b/records.py index b6c8c7d..c5b2d62 100644 --- a/records.py +++ b/records.py @@ -263,15 +263,14 @@ def cli(): A Kenneth Reitz project. Usage: - records [-i] [--params ...] [--url=] + records [--params ...] [--url=] records (-h | --help) Options: - -h --help Show this screen. - --url= The database URL to use. Defaults to $DATABASE_URL. - --params Prameterized query. Subsequent arguments are treated as - parameters to the query. - -i --interactive An interactive interpreter. + -h --help Show this screen. + --url= The database URL to use. Defaults to $DATABASE_URL. + --params Parameterized query. Subsequent arguments are treated + as parameters to the query. Supported Formats: csv, tsv, json, yaml, html, xls, xlsx, dbf, latex, ods @@ -286,8 +285,6 @@ Notes: can be provided instead. Use this feature discernfully; it's dangerous. - Records is intended for report-style exports of database queries, and has not yet been optimized for extremely large data dumps. - - Interactive mode is experimental and may be removed at any time. - Feedback, as always, is much appreciated! --me@kennethreitz.org Cake: ✨ 🍰 ✨ @@ -296,13 +293,6 @@ Cake: # Parse the command-line arguments. arguments = docopt(cli_docs) - # print arguments - # exit() - - # Cleanup docopt parsing errors. - if arguments['--params'] and arguments[''] not in supported_formats: - arguments[''].insert(0, arguments['']) - arguments[''] = None # Create the Database. db = Database(arguments['--url']) @@ -310,6 +300,10 @@ Cake: query = arguments[''] params = arguments[''] + # Can't send an empty list if params aren't expected. + if not len(params): + params = None + # Execute the query, if it is a found file. if os.path.isfile(query): rows = db.query_file(query, params) @@ -323,12 +317,6 @@ Cake: print('The given query could not be found.') exit(66) - # Interactive mode. - if arguments['--interactive']: - interactive_env = {'db': db, 'rows': rows} - interact(interactive_env, local=interactive_env) - exit() - # Print results in desired format. if arguments['']: print(rows.export(arguments['']))