Browse Source

update argument parser help

Tobias Simetsreiter 5 years ago
parent
commit
a285d125a2
1 changed files with 33 additions and 9 deletions
  1. 33 9
      abe_setup.py

+ 33 - 9
abe_setup.py

@@ -15,6 +15,10 @@ def main():
 
     count_submodules = 0
 
+    url = sane_origin_url( args.source_url, args.output_dir )
+
+    sub = AbeSubmodule([args.output_dir, url.geturl(), args.tag], AbeSubType.SUBMODULE)
+
     if args.abe_command:
         executeAbeCommand( args.output_dir, args.abe_command )
     else:
@@ -24,8 +28,14 @@ def main():
                 print("Count:",count_submodules)
 
             if args.execute_command:
-                from subprocess import run
-                run(args.execute_command, shell=True,check=True, cwd=sub.fullpath)
+                from subprocess import run, CalledProcessError
+                import sys
+                try:
+                    run(args.execute_command, shell=True,check=True, cwd=sub.fullpath)
+                except CalledProcessError as err:
+                    print(f"Command: \"{args.execute_command}\" in \"{sub.fullpath}\" returned exitcode \"{err.returncode}\"")
+                    sys.exit(err.returncode)
+
             else:
                 clone_repo_cached( sub, cache_dir=args.cache_dir, fetch_origin=(not args.no_fetch_origin))
 
@@ -33,15 +43,29 @@ def main():
 def parser():
     import argparse
     p = argparse.ArgumentParser()
-    p.add_argument('-a', '--abe_command', default=None)
     p.add_argument('-d', '--debug', action='count', default=1)
     p.add_argument('-q', '--quiet', action='store_true')
-    p.add_argument('-o', '--output_dir', default='.')
-    p.add_argument('-c', '--cache_dir', default=None)
-    p.add_argument('-n', '--no_fetch_origin', action='store_true')
-    p.add_argument('-t', '--tag', default='master')
-    p.add_argument('-s', '--source_url', default=None)
-    p.add_argument('-x', '--execute_command', default=None)
+    p.add_argument('-o', '--output_dir',
+                   default='.',
+                   help='local directory to operate on')
+    p.add_argument('-c', '--cache_dir',
+                   default=None,
+                   help='use a separate local directory to cache git repositories')
+    p.add_argument('-n', '--no_fetch_origin',
+                   action='store_true',
+                   help='prevent fetching from origin')
+    p.add_argument('-t', '--tag',
+                   default='master',
+                   help='commit/branch/tag to be checked out')
+    p.add_argument('-s', '--source_url',
+                   default=None,
+                   help='url to be used for origin remote')
+    p.add_argument('-a', '--abe_command',
+                   default=None,
+                   help="execute an ABE command in output_dir")
+    p.add_argument('-x', '--execute_command',
+                   default=None,
+                   help='execute command in subdirs recursively')
     return p
 
 def executeAbeCommand( repo_path, command_name ):