Commit 5246d815 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: new --force argument, which disables prompting of dest dir. main func can be

passed argv. More general download failures are absorbed
parent 9b918c3b
......@@ -122,7 +122,11 @@ def parseArgs(argv : List[str]) -> argparse.Namespace:
'be specified for each plugin that is specified on '
'the command-line. If not provided, you will be '
'prompted to select the destination directory for '
'each plugin.'
'each plugin.',
'force' : 'If used, you will not be asked any questions, and '
'all default settings will be applied. Can only be '
'used when the plugins you wish to have installed '
'are specified on the command-line. '
parser = argparse.ArgumentParser(
......@@ -138,6 +142,8 @@ def parseArgs(argv : List[str]) -> argparse.Namespace:
'-a', '--archiveDir', default=ARCHIVE_DIR, help=helps['archiveDir'])
'-d', '--destination', action='append', help=helps['destination'])
'-f', '--force', action='store_true', help=helps['force'])
args = parser.parse_args(argv)
......@@ -149,6 +155,10 @@ def parseArgs(argv : List[str]) -> argparse.Namespace:
parser.error('The --destination option must either be specified '
'exactly once, or once for every requested plugin.')
if args.force and len(args.plugin) == 0:
parser.error('The --force option may only be used when you specify '
'which plugins to install on the command line.')
# make all destination paths absolute,
# and support tilde/envvar expansion
if args.destination is not None:
......@@ -236,8 +246,9 @@ def selectPlugins(args : argparse.Namespace,
# if the user did not specify install
# destinations, ask them to confirm
# the destination directory for each
# plugin
if args.destination is None:
# plugin (unless --force is active,
# in which case defaults are used)
if args.destination is None and (not args.force):
return plugins
......@@ -268,7 +279,7 @@ def download(args : argparse.Namespace, plugins : List[plgman.Plugin]):
plugin, args.archiveDir)
plugin.archiveFile = archiveFile
except routines.DownloadFailed as e:
except Exception as e:
......@@ -288,10 +299,13 @@ def install(args : argparse.Namespace, plugins : List[plgman.Plugin]):
def main():
def main(argv=None):
"""Entry point for the ``fsl_add_module`` script. """
args = parseArgs(sys.argv[1:])
if argv is None:
argv = sys.argv[1:]
args = parseArgs(argv)
important(f'fsl_add_module {__VERSION__}. Press CTRL+C '
'at any point to exit.', UNDERLINE, EMPHASIS)
Supports Markdown
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