diff --git a/swh/core/cli.py b/swh/core/cli.py --- a/swh/core/cli.py +++ b/swh/core/cli.py @@ -21,10 +21,11 @@ @click.argument('module', nargs=-1, required=True) @click.option('--db-name', '-d', help='Database name.', default='softwareheritage-dev', show_default=True) -@click.option('--no-create', '-C', - help='Do not attempt to create the database', default=False) -def db_init(module, db_name=None, no_create=None): - """Create and initialise a database for the Software Heritage . +@click.option('--create/--no-create', '-C', is_flag=True, + help='Attempt to create the database', default=True) +def db_init(module, db_name=None, create=True): + """Initialise a database for the Software Heritage . By + default, attempts to create the database first. Example: @@ -58,7 +59,7 @@ '(no sql/ dir)'.format(modname)) dump_files.extend(sorted(glob.glob(path.join(sqldir, '*.sql')), key=sortkey)) - if not no_create: + if create: pg_createdb(db_name) dump_files = [(x, DB_DUMP_TYPES[path.splitext(x)[1]])