@@ -428,6 +428,8 @@ def do_add_parser(self, parser_adder):
428428 epilog = f'''\
429429{ ACTIVE_PROJECTS_HELP }
430430
431+ Note: To list only inactive projects you can use --inactive.
432+
431433FORMAT STRINGS
432434--------------
433435
@@ -453,11 +455,15 @@ def do_add_parser(self, parser_adder):
453455 that the project has been cloned.
454456- cloned: "cloned" if the project has been cloned, "not-cloned"
455457 otherwise
458+ - active: "active" if the project is currently active, "inactive" otherwise
456459- clone_depth: project clone depth if specified, "None" otherwise
457460- groups: project groups, as a comma-separated list
458461''' )
459- parser .add_argument ('-a' , '--all' , action = 'store_true' ,
460- help = 'include inactive projects' ),
462+ group = parser .add_mutually_exclusive_group (required = False )
463+ group .add_argument ('-a' , '--all' , action = 'store_true' ,
464+ help = 'include inactive projects' ),
465+ group .add_argument ('-i' , '--inactive' , action = 'store_true' ,
466+ help = 'list only inactive projects' ),
461467 parser .add_argument ('--manifest-path-from-yaml' , action = 'store_true' ,
462468 help = '''print the manifest repository's path
463469 according to the manifest file YAML, which may
@@ -491,15 +497,27 @@ def cloned_thunk(project):
491497
492498 return "cloned" if project .is_cloned () else "not-cloned"
493499
500+ def active_thunk (project ):
501+ self .die_if_no_git ()
502+
503+ return "active" if self .manifest .is_active (project ) else "inactive"
504+
494505 def delay (func , project ):
495506 return DelayFormat (partial (func , project ))
496507
508+ if args .inactive and args .projects :
509+ self .parser .error ('-i cannot be combined with an explicit project '
510+ 'list' )
511+
497512 for project in self ._projects (args .projects ):
498- # Skip inactive projects unless the user said
513+ # Include the project based on the inactive flag. If the flag is
514+ # set, include only inactive projects. Otherwise, include only
515+ # active ones.
516+ include = self .manifest .is_active (project ) != bool (args .inactive )
517+ # Skip active or inactive projects unless the user said
499518 # --all or named some projects explicitly.
500- if not (args .all or args .projects or
501- self .manifest .is_active (project )):
502- self .dbg (f'{ project .name } : skipping inactive project' )
519+ if not (args .all or args .projects or include ):
520+ self .dbg (f'{ project .name } : skipping project' )
503521 continue
504522
505523 # Spelling out the format keys explicitly here gives us
@@ -538,6 +556,7 @@ def delay(func, project):
538556 revision = project .revision or 'N/A' ,
539557 clone_depth = project .clone_depth or "None" ,
540558 cloned = delay (cloned_thunk , project ),
559+ active = delay (active_thunk , project ),
541560 sha = delay (sha_thunk , project ),
542561 groups = ',' .join (project .groups ))
543562 except KeyError as e :
0 commit comments