summaryrefslogtreecommitdiffstats
path: root/subcmds/list.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-08-27 01:10:59 -0400
committerMike Frysinger <vapier@google.com>2019-08-28 03:54:11 +0000
commitae6cb08ae52d488a4cc6892f811c1c1acf8c3c12 (patch)
treec927415df288d9bf9076e758835db53cc633597d /subcmds/list.py
parent3fc157285cb61d6a4faa55dc4f011fb94d598c20 (diff)
downloadgit-repo-ae6cb08ae52d488a4cc6892f811c1c1acf8c3c12.tar.gz
split out cli validation from executionv1.13.5
A common pattern in our subcommands is to verify the arguments & options before executing things. For some subcommands, that check stage is quite long which makes the execution function even bigger. Lets split that logic out of the execute phase so it's easier to manage these. This is most noticeable in the sync subcommand whose Execute func is quite large, and the option checking makes up ~15% of it. The manifest command's Execute can be simplified significantly as the optparse configuration always sets output_file to a string. Change-Id: I7097847ff040e831345e63de6b467ee17609990e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/234834 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/list.py')
-rw-r--r--subcmds/list.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/subcmds/list.py b/subcmds/list.py
index 961b1956..00172f0e 100644
--- a/subcmds/list.py
+++ b/subcmds/list.py
@@ -49,6 +49,10 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
49 dest='path_only', action='store_true', 49 dest='path_only', action='store_true',
50 help="Display only the path of the repository") 50 help="Display only the path of the repository")
51 51
52 def ValidateOptions(self, opt, args):
53 if opt.fullpath and opt.name_only:
54 self.OptionParser.error('cannot combine -f and -n')
55
52 def Execute(self, opt, args): 56 def Execute(self, opt, args):
53 """List all projects and the associated directories. 57 """List all projects and the associated directories.
54 58
@@ -60,11 +64,6 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
60 opt: The options. 64 opt: The options.
61 args: Positional args. Can be a list of projects to list, or empty. 65 args: Positional args. Can be a list of projects to list, or empty.
62 """ 66 """
63
64 if opt.fullpath and opt.name_only:
65 print('error: cannot combine -f and -n', file=sys.stderr)
66 sys.exit(1)
67
68 if not opt.regex: 67 if not opt.regex:
69 projects = self.GetProjects(args, groups=opt.groups) 68 projects = self.GetProjects(args, groups=opt.groups)
70 else: 69 else: