Add a debug() function to allow command line debugging of the vcs code

This commit is contained in:
Kovid Goyal 2013-05-04 09:43:17 +05:30
parent 41783344a8
commit cdbe85bbde
1 changed files with 20 additions and 0 deletions

View File

@ -201,3 +201,23 @@ def guess(path):
except:
pass
return None
def debug():
''' To use run python -c "from powerline.lib.vcs import debug; debug()" some_file_to_watch '''
import sys
dest = sys.argv[-1]
repo = guess(dest)
if repo is None:
print ('%s is not a recognized vcs repo' % dest)
raise SystemExit(1)
print ('Watching %s' % dest)
print ('Press Ctrl-C to exit.')
try:
while True:
if os.path.isdir(dest):
print ('Branch name: %s Status: %s' % (repo.branch(), repo.status()))
else:
print ('File status: %s' % repo.status(dest))
raw_input('Press Enter to check again: ')
except KeyboardInterrupt:
pass