Commit 7780ed3e authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[databases] Improved process argument handling

parent 22523a95
......@@ -652,65 +652,71 @@ def view_outputs(configuration, dataset_name, excluded_outputs=None, uid=None,
def process(args):
uid = int(args['--uid']) if args['--uid'] is not None else None
configuration = args['config']
db_names = args['<name>']
if args['list']:
if args['--remote']:
with common.make_webapi(args['config']) as webapi:
with common.make_webapi(configuration) as webapi:
return common.display_remote_list(webapi, 'database')
else:
return common.display_local_list(args['config'].path, 'database')
return common.display_local_list(configuration.path, 'database')
elif args['check']:
return common.check(args['config'].path, 'database', args['<name>'])
return common.check(configuration.path, 'database', db_names)
elif args['pull']:
with common.make_webapi(args['config']) as webapi:
return pull(webapi, args['config'].path, args['<name>'],
with common.make_webapi(configuration) as webapi:
return pull(webapi, configuration.path, db_names,
args['--force'], 0, {})
elif args['push']:
with common.make_webapi(args['config']) as webapi:
return common.push(webapi, args['config'].path, 'database',
args['<name>'], ['name', 'declaration',
'code', 'description'],
with common.make_webapi(configuration) as webapi:
return common.push(webapi, configuration.path, 'database',
db_names, ['name', 'declaration',
'code', 'description'],
{}, args['--force'], args['--dry-run'], 0)
elif args['diff']:
with common.make_webapi(args['config']) as webapi:
return common.diff(webapi, args['config'].path, 'database',
args['<name>'][0], ['declaration', 'code', 'description'])
with common.make_webapi(configuration) as webapi:
return common.diff(webapi, configuration.path, 'database',
db_names[0],
['declaration', 'code', 'description'])
elif args['status']:
with common.make_webapi(args['config']) as webapi:
return common.status(webapi, args['config'].path, 'database')[0]
with common.make_webapi(configuration) as webapi:
return common.status(webapi, configuration.path, 'database')[0]
elif args['version']:
return common.new_version(args['config'].path, 'database',
args['<name>'][0])
return common.new_version(configuration.path, 'database',
db_names[0])
elif args['view']:
if args['--exclude']:
return view_outputs(args['config'], args['<set_name>'], args['--exclude'],
uid=int(
args['--uid']) if args['--uid'] is not None else None,
db_root=args['--db-root'], docker=args['--docker'])
return view_outputs(configuration, args['<set_name>'],
args['--exclude'],
uid=uid,
db_root=args['--db-root'],
docker=args['--docker'])
else:
return view_outputs(args['config'], args['<set_name>'],
uid=int(
args['--uid']) if args['--uid'] is not None else None,
db_root=args['--db-root'], docker=args['--docker'])
return view_outputs(configuration, args['<set_name>'],
uid=uid,
db_root=args['--db-root'],
docker=args['--docker'])
elif args['index']:
if args['--list']:
return list_index_files(args['config'], args['<name>'])
return list_index_files(configuration, db_names)
elif args['--delete']:
return delete_index_files(args['config'], args['<name>'])
return delete_index_files(configuration, db_names)
elif args['--checksum']:
return checksum_index_files(args['config'], args['<name>'])
return checksum_index_files(configuration, db_names)
else:
return index_outputs(args['config'], args['<name>'],
uid=int(
args['--uid']) if args['--uid'] is not None else None,
db_root=args['--db-root'], docker=args['--docker'])
return index_outputs(configuration, db_names,
uid=uid,
db_root=args['--db-root'],
docker=args['--docker'])
# Should not happen
logger.error("unrecognized `databases' subcommand")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment