Skip to content

Commit

Permalink
Change CLI arguments
Browse files Browse the repository at this point in the history
Allow the database connection string to be pulled from an envvar.
  • Loading branch information
Mike Graves committed Mar 3, 2017
1 parent 55ddd8a commit f8ae7f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions carbon/cli.py
Expand Up @@ -9,19 +9,21 @@

@click.command()
@click.version_option()
@click.argument('db')
@click.argument('feed_type', type=click.Choice(['people', 'articles']))
@click.option('--db', envvar='CARBON_DB', help='Database connection string')
@click.option('-o', '--out', help='Output file', type=click.File('wb'),
default='-')
def main(db, feed_type, out):
def main(feed_type, db, out):
"""Generate feeds for Symplectic Elements.
The data is pulled from a database identified by DB, which should
be a valid SQLAlchemy database connection string. For oracle use:
The data is pulled from a database identified by --db, which should
be a valid SQLAlchemy database connection string. This can also be
omitted and pulled from an environment variable named CARBON_DB. For
oracle use:
oracle://<username>:<password>@<server>:1521/<sid>
The feed will be printed to stdout if OUT is not specified.
The feed will be printed to stdout if -o/--out is not specified.
FEED_TYPE should be 'people' or 'articles'.
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Expand Up @@ -17,14 +17,14 @@ def runner():


def test_people_returns_people(runner, xml_data):
res = runner.invoke(main, ['sqlite://', 'people'])
res = runner.invoke(main, ['--db', 'sqlite://', 'people'])
assert res.exit_code == 0
assert res.output_bytes == \
ET.tostring(xml_data, encoding="UTF-8", xml_declaration=True)


def test_articles_returns_articles(runner, articles_data):
res = runner.invoke(main, ['sqlite://', 'articles'])
res = runner.invoke(main, ['--db', 'sqlite://', 'articles'])
assert res.exit_code == 0
assert res.output_bytes == \
ET.tostring(articles_data, encoding='UTF-8', xml_declaration=True)

0 comments on commit f8ae7f9

Please sign in to comment.