moved command line args handling into function
This commit is contained in:
37
snek
37
snek
@ -2,29 +2,31 @@
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="🐍",
|
||||
# formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||
)
|
||||
def handle_clargs():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="🐍",
|
||||
# formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||
)
|
||||
|
||||
parser.add_argument("--root", help="conda root folder / prefix (read from the current env, if not given)")
|
||||
parser.add_argument("--exe", help="conda or mamba executable (read from the current env, if not given)")
|
||||
parser.add_argument("--root", help="conda root folder / prefix (read from the current env, if not given)")
|
||||
parser.add_argument("--exe", help="conda or mamba executable (read from the current env, if not given)")
|
||||
|
||||
subparsers = parser.add_subparsers(title="commands", dest="command", required=True)
|
||||
subparsers = parser.add_subparsers(title="commands", dest="command", required=True)
|
||||
|
||||
parser_envs = subparsers.add_parser("envs", help="print existing envs")
|
||||
parser_root = subparsers.add_parser("root", help="print root")
|
||||
parser_exe = subparsers.add_parser("exe", help="print exe")
|
||||
parser_info = subparsers.add_parser("info", help="print info")
|
||||
parser_envs = subparsers.add_parser("envs", help="print existing envs")
|
||||
parser_root = subparsers.add_parser("root", help="print root")
|
||||
parser_exe = subparsers.add_parser("exe", help="print exe")
|
||||
parser_info = subparsers.add_parser("info", help="print info")
|
||||
|
||||
parser_fork = subparsers.add_parser("fork", help="fork a conda env")
|
||||
parser_bless = subparsers.add_parser("bless", help="bless a conda env")
|
||||
parser_fork = subparsers.add_parser("fork", help="fork a conda env")
|
||||
parser_bless = subparsers.add_parser("bless", help="bless a conda env")
|
||||
|
||||
msg = "name of the conda env"
|
||||
parser_fork.add_argument("name", help=msg)
|
||||
parser_bless.add_argument("name", help=msg)
|
||||
msg = "name of the conda env"
|
||||
parser_fork.add_argument("name", help=msg)
|
||||
parser_bless.add_argument("name", help=msg)
|
||||
|
||||
clargs = parser.parse_args()
|
||||
clargs = parser.parse_args()
|
||||
return clargs
|
||||
|
||||
|
||||
|
||||
@ -165,6 +167,7 @@ def maxstrlen(seq):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
clargs = handle_clargs()
|
||||
conda = Conda(root=clargs.root, exe=clargs.exe)
|
||||
|
||||
dispatch = {
|
||||
|
Reference in New Issue
Block a user