aboutsummaryrefslogtreecommitdiffstats
path: root/dotfiles.py
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2016-01-04 14:56:50 -0500
committerGravatar Jon Bernard <jbernard@tuxion.com> 2016-01-04 14:56:50 -0500
commit87fa2782267170afe0812c6a98ec21b3b1631ab7 (patch)
tree2a435eaf5d8f6f92533d1140d027ee22f753d216 /dotfiles.py
parentdac08d6522270d4ad312efabdba02aff121af1e3 (diff)
downloaddotfiles-87fa2782267170afe0812c6a98ec21b3b1631ab7.tar.gz
dotfiles-87fa2782267170afe0812c6a98ec21b3b1631ab7.tar.bz2
dotfiles-87fa2782267170afe0812c6a98ec21b3b1631ab7.zip
Cleanup verbose status function
Diffstat (limited to 'dotfiles.py')
-rw-r--r--dotfiles.py22
1 files changed, 15 insertions, 7 deletions
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)