Skip to content

Commit

Permalink
Improve argument handling in powerline script
Browse files Browse the repository at this point in the history
Modules can now be any string, and an informative error message will be
written to sys.stdout if the module doesn't exist. The
`last_pipe_status` argument will also automatically be split into
a list.
  • Loading branch information
Lokaltog committed Jan 28, 2013
1 parent 5db6f47 commit 2979325
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions powerline/segments/shell.py
Expand Up @@ -7,10 +7,9 @@ def last_status(segment_info):


def last_pipe_status(segment_info):
pipe_status = [int(status) for status in segment_info.last_pipe_status.split()]
if any(pipe_status):
if any(segment_info.last_pipe_status):
return [{"contents": str(status), "highlight_group": "exit_fail" if status else "exit_success"}
for status in pipe_status]
for status in segment_info.last_pipe_status]
else:
return None
last_pipe_status.requires_powerline_segment_info = True
6 changes: 3 additions & 3 deletions scripts/powerline
Expand Up @@ -14,10 +14,10 @@ except ImportError:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('ext', nargs=1)
parser.add_argument('side', nargs='?', choices=('left', 'right'))
parser.add_argument('-r', '--renderer_module', choices=('shell', 'zsh_prompt', 'tmux'))
parser.add_argument('-r', '--renderer_module', metavar='MODULE', type=str)
parser.add_argument('-w', '--width', type=int)
parser.add_argument('--last_exit_code', type=int, metavar='INT')
parser.add_argument('--last_pipe_status', metavar='LIST')
parser.add_argument('--last_exit_code', metavar='INT', type=int)
parser.add_argument('--last_pipe_status', metavar='LIST', default='', type=lambda s: [int(status) for status in s.split()])

if __name__ == '__main__':
args = parser.parse_args()
Expand Down

0 comments on commit 2979325

Please sign in to comment.