From 87fa2782267170afe0812c6a98ec21b3b1631ab7 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Mon, 4 Jan 2016 14:56:50 -0500 Subject: Cleanup verbose status function --- dotfiles.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'dotfiles.py') diff --git a/dotfiles.py b/dotfiles.py index 460f5f3..11c62d1 100644 --- a/dotfiles.py +++ b/dotfiles.py @@ -154,29 +154,35 @@ def show_status(dotfiles, state_info, color): def show_verbose_status(dotfiles, state_info, color): errors = [d for d in dotfiles if d.state == 'error'] - conflicts = [d for d in dotfiles if d.state == 'conflict'] missing = [d for d in dotfiles if d.state == 'missing'] + conflicts = [d for d in dotfiles if d.state == 'conflict'] - def _show(dotfiles, state): + def _show(dotfiles, state, color): for dotfile in dotfiles: - click.secho(' %s: %s' % (state, dotfile), - fg=state_info[state]['color'] if color else None) + click.secho(' %s: %s' % (state, dotfile), fg=color) if errors: click.echo('Dotfiles with no target:\n') - _show(errors, 'error') + _show(errors, 'error', + state_info['error']['color'] if color else None) click.echo() if conflicts: click.echo('Repository and home directory files are different:\n') - _show(conflicts, 'conflict') + _show(conflicts, 'conflict', + state_info['conflict']['color'] if color else None) click.echo() if missing: click.echo('Missing symlink in home directory:\n') - _show(missing, 'missing') + _show(missing, 'missing', + state_info['missing']['color'] if color else None) click.echo() + total = len(errors) + len(conflicts) + len(missing) + click.echo("%s dotfile%s need%s attention" % + (total, 's' if total > 1 else '', '' if total > 1 else 's')) + @cli.command() @click.option('-c', '--color', is_flag=True, help='Enable color.') @@ -192,6 +198,8 @@ def status(repo, color, verbose): } dotfiles = repo.contents() + if not dotfiles: + return if verbose: show_verbose_status(dotfiles, state_info, color) -- cgit v1.2.3