git-status-all: add -l to just list the dirty directories

master
neingeist 11 months ago
parent de53cc79c2
commit 9e473bced8

@ -40,7 +40,9 @@ def working_directory(directory: Path):
@click.command @click.command
@click.argument('topdirs', nargs=-1) @click.argument('topdirs', nargs=-1)
def search_dirty(topdirs): @click.option('-l', '--list', 'list_', is_flag=True, default=False,
help='Just list the dirty directories')
def search_dirty(topdirs, list_):
"""Search for dirty git working directories in TOPDIRS""" """Search for dirty git working directories in TOPDIRS"""
if len(topdirs) == 0: if len(topdirs) == 0:
topdirs = ["."] topdirs = ["."]
@ -57,7 +59,10 @@ def search_dirty(topdirs):
try: try:
out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT) out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT)
if len(out) > 0: if len(out) > 0:
print('== {}\n{}'.format(work_tree_directory, out.decode('utf-8'))) if not list_:
print('== {}\n{}'.format(work_tree_directory, out.decode('utf-8')))
else:
print(work_tree_directory)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print((Fore.RED + 'git status is unhappy with {}' + Fore.RESET) print((Fore.RED + 'git status is unhappy with {}' + Fore.RESET)
.format(work_tree_directory)) .format(work_tree_directory))

Loading…
Cancel
Save