Revert "Remove the -f flag before it gains too much use."

As @npetroni quite rightly pointed out, the purpose of the CLI is to
make it easy for people to use on the commandline, so at the expense of
some dynamic ability, -f is returning for convenience purposes.

This reverts commit 4450766d50.
This commit is contained in:
Mike Auty
2018-05-23 22:08:52 +01:00
parent 87d0f97f52
commit d6b7415bab
+14
View File
@@ -82,6 +82,8 @@ class CommandLine(interfaces.plugins.FileConsumerInterface):
parser.add_argument("-q", "--quiet", help = "Remove progress feedback", default = False, action = 'store_true')
parser.add_argument("-l", "--log", help = "Log output to a file as well as the console", default = None,
type = str)
parser.add_argument("-f", help = "Shorthand for --single-location=file:// if single-location is not defined",
default = None, type = str)
parser.add_argument("--write-config", help = "Write configuration JSON file out to config.json",
default = False,
action = 'store_true')
@@ -144,6 +146,18 @@ class CommandLine(interfaces.plugins.FileConsumerInterface):
plugin = plugin_list[args.plugin]
plugin_config_path = interfaces.configuration.path_join('plugins', plugin.__name__)
# Special case the -f argument because people use is so frequently
# It has to go here so it can be overridden by single-location if it's defined
# NOTE: This will *BREAK* if LayerStacker, or the automagic configuration system, changes at all
###
if args.f:
file_name = os.path.abspath(args.f)
if not os.path.exists(file_name):
vollog.log(logging.INFO, "File does not exist: {}".format(file_name))
else:
single_location = "file:" + request.pathname2url(file_name)
ctx.config['automagic.LayerStacker.single_location'] = single_location
# UI fills in the config, here we load it from the config file and do it before we process the CL parameters
if args.config:
with open(args.config, "r") as f: