Commit bd3140f9 authored by Flavio TARSETTI's avatar Flavio TARSETTI

[all_packages] added set options to use first the value set in the config file

parent c9ca1c80
Pipeline #20406 passed with stages
in 27 minutes and 24 seconds
......@@ -359,7 +359,7 @@ def process(args):
return common.display_local_path(args['config'].path, 'algorithm', args['<name>'])
elif args['edit']:
return common.edit_local_file(args['config'].path, 'algorithm', args['<name>'][0])
return common.edit_local_file(args['config'].path, args['config'].editor, 'algorithm', args['<name>'][0])
elif args['check']:
return common.check(args['config'].path, 'algorithm', args['<name>'])
......
......@@ -526,7 +526,7 @@ def display_local_path(prefix, type, names):
return 0
def edit_local_file(prefix, type, name):
def edit_local_file(prefix, editor, type, name):
'''Implements the local "path" command
......@@ -574,14 +574,15 @@ def edit_local_file(prefix, type, name):
try:
if os.path.isfile(object_path):
# check if editor set
if len(os.environ['VISUAL']) > 0:
editor = os.environ['VISUAL']
elif len(os.environ['EDITOR']) > 0:
editor = os.environ['EDITOR']
else:
logger.error("No default editor set in your environment variable")
return 1
logger.info("Editing object of type '%s' and name '%s':", selected_type, name)
if editor is None:
if len(os.environ['VISUAL']) > 0:
editor = os.environ['VISUAL']
elif len(os.environ['EDITOR']) > 0:
editor = os.environ['EDITOR']
else:
logger.error("No default editor set in your environment variable")
return 1
logger.info("Editing object of type '%s' and name '%s'", selected_type, name)
cmd = "%s %s"%(editor, object_path)
os.system(cmd)
else:
......
......@@ -82,6 +82,7 @@ DEFAULTS = {
'token': None,
'prefix': os.path.realpath(os.path.join(os.curdir, 'prefix')),
'cache': 'cache',
'editor': None,
}
"""Default values for the command-line utility"""
......@@ -92,6 +93,7 @@ DOC = {
'token': 'Secret key of the user on the BEAT platform',
'prefix': 'Directory containing BEAT objects',
'cache': 'Directory to use for data caching (relative to prefix)',
'editor': 'Editor to be used to edit local files',
}
"""Documentation for configuration parameters"""
......
......@@ -648,7 +648,7 @@ def process(args):
return common.display_local_path(configuration.path, 'database', db_names)
elif args['edit']:
return common.edit_local_file(configuration.path, 'database', db_names[0])
return common.edit_local_file(configuration.path, configuration.editor, 'database', db_names[0])
elif args['check']:
return common.check(configuration.path, 'database', db_names)
......
......@@ -159,7 +159,7 @@ def process(args):
return common.display_local_path(args['config'].path, 'dataformat', args['<name>'])
elif args['edit']:
return common.edit_local_file(args['config'].path, 'dataformat', args['<name>'][0])
return common.edit_local_file(args['config'].path, args['config'].editor, 'dataformat', args['<name>'][0])
elif args['check']:
return common.check(args['config'].path, 'dataformat', args['<name>'])
......
......@@ -606,7 +606,7 @@ def process(args):
return common.display_local_path(config.path, 'experiment', names)
elif args['edit']:
return common.edit_local_file(config.path, 'experiment', names[0])
return common.edit_local_file(config.path, config.editor, 'experiment', names[0])
elif args['check']:
return common.check(config.path, 'experiment', names)
......
......@@ -154,7 +154,7 @@ def process(args):
return common.display_local_path(args['config'].path, 'library', args['<name>'])
elif args['edit']:
return common.edit_local_file(args['config'].path, 'library', args['<name>'][0])
return common.edit_local_file(args['config'].path, args['config'].editor, 'library', args['<name>'][0])
elif args['check']:
return common.check(args['config'].path, 'library', args['<name>'])
......
......@@ -121,7 +121,7 @@ def process(args):
return common.display_local_path(args['config'].path, 'plotterparameter', args['<name>'])
elif args['edit']:
return common.edit_local_file(args['config'].path, 'plotterparameter', args['<name>'][0])
return common.edit_local_file(args['config'].path, args['config'].editor, 'plotterparameter', args['<name>'][0])
elif args['check']:
return common.check(args['config'].path, 'plotterparameter', args['<name>'])
......
......@@ -286,7 +286,7 @@ def process(args):
return common.display_local_path(args['config'].path, 'plotter', args['<name>'])
elif args['edit']:
return common.edit_local_file(args['config'].path, 'plotter', args['<name>'][0])
return common.edit_local_file(args['config'].path, args['config'].editor, 'plotter', args['<name>'][0])
elif args['check']:
return common.check(args['config'].path, 'plotter', args['<name>'])
......
......@@ -30,7 +30,7 @@
Usage:
%(prog)s [--verbose ...] [--prefix=<path>] [--cache=<path>] [--user=<user>]
[--platform=<url>] [--token=<token>]
[--platform=<url>] [--token=<token>] [--editor=<editor>]
[--test-mode] <command> [<args>...]
%(prog)s (--help | -h)
%(prog)s (--version | -V)
......@@ -49,6 +49,9 @@ Options:
-t, --token=<token> Overrides the user token for server operations. If not
set, use the value from your RC file. There are no
defaults for this option.
-e, --editor=<editor> Overrides the user editor to edit local files. If not
set, use the value from your environment. There are no
defaults for this option.
-u, --user=<user> Overrides the user name on the remote platform. If not
set, use the value from your RC file.
[default: %(user)s]
......
......@@ -84,7 +84,7 @@ def process(args):
return common.display_local_path(args['config'].path, 'toolchain', args['<name>'])
elif args['edit']:
return common.edit_local_file(args['config'].path, 'toolchain', args['<name>'][0])
return common.edit_local_file(args['config'].path, args['config'].editor, 'toolchain', args['<name>'][0])
elif args['check']:
return common.check(args['config'].path, 'toolchain', args['<name>'])
......
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