Use Python `argparser` to parse arguments of CLI commands instead of bash script
Node CLI uses bash script to parse CLI commands, and executes node.cli
with corresponding option. This approach duplicates options and parsing in both bash and node.cli
. For example: fedbiomed_run node add
parses add
command and executes fedbiomed.node.cli -a | --add
. So add
command is parsed both in bash and python.
Since the Fed-BioMed CLI is more mature in having more options than before, the CLI module needs to be refactored for simplicity's sake.
1 - Option that are given after fedbiomed_run node [...]
can passed directy to the fedbiomed.cli
.
2 - Instead of using if
and else
in fedbiomed.node.cli
use subparsers
. here is an example use of subparser
parser = argparse.ArgumentParser()
subparsers = parse.add_subparsers()
database_add = subparsers.add_parser("add", help="Help string")
database_add.set_defaults(func=add_dataset)
def add_dataset(args):
# Access extra arguments through `args`
pass