implement subcommand shortcuts as default aliases in the user configuration

This commit is contained in:
Josh Holtrop 2012-03-22 14:23:38 -04:00
parent bb97b312e6
commit 40775d6d72

54
jsvn
View File

@ -127,7 +127,42 @@ def get_config():
'pager': 'less -FRX', 'pager': 'less -FRX',
'use_pager': True, 'use_pager': True,
'use_color': True, 'use_color': True,
'aliases': {}, 'aliases': {
# default Subversion aliases
'praise': 'blame',
'annotate': 'blame',
'ann': 'blame',
'cl': 'changelist',
'co': 'checkout',
'ci': 'commit',
'cp': 'copy',
'del': 'delete',
'remove': 'delete',
'rm': 'delete',
'di': 'diff',
'?': 'help',
'h': 'help',
'ls': 'list',
'mv': 'move',
'rename': 'move',
'ren': 'move',
'pdel': 'propdel',
'pd': 'propdel',
'pedit': 'propedit',
'pe': 'propedit',
'pget': 'propget',
'pg': 'propget',
'plist': 'proplist',
'pl': 'proplist',
'pset': 'propset',
'ps': 'propset',
'stat': 'status',
'st': 'status',
'sw': 'switch',
'up': 'update',
# default jsvn aliases
'tags': 'tag',
'branches': 'branch'},
'svn': '', 'svn': '',
} }
pth = os.path.expanduser('~/.jsvn') pth = os.path.expanduser('~/.jsvn')
@ -732,14 +767,8 @@ def main(argv):
using_color = sys.stdout.isatty() and config['use_color'] using_color = sys.stdout.isatty() and config['use_color']
if sys.stdout.isatty() and config['use_pager']: if sys.stdout.isatty() and config['use_pager']:
if (len(argv) >= 1 and argv[0] in if (len(argv) >= 1 and argv[0] in
('blame', 'praise', 'annotate', 'ann', ('blame', 'cat', 'diff', 'help', 'list', 'log',
'cat', 'propget', 'proplist')):
'diff', 'di',
'help',
'list', 'ls',
'log',
'propget', 'pget', 'pg',
'proplist', 'plist', 'pl')):
pager = config['pager'] pager = config['pager']
if 'PAGER' in os.environ and os.environ['PAGER'] != '': if 'PAGER' in os.environ and os.environ['PAGER'] != '':
pager = os.environ['PAGER'] pager = os.environ['PAGER']
@ -754,26 +783,19 @@ def main(argv):
handlers = { handlers = {
'add': add, 'add': add,
'branch': branch, 'branch': branch,
'branches': branch,
'externals': externals, 'externals': externals,
'switch': switch, 'switch': switch,
'sw': switch,
'merge': merge, 'merge': merge,
'tag': tag, 'tag': tag,
'tags': tag,
'diff': diff, 'diff': diff,
'di': diff,
'log': log, 'log': log,
'root': root, 'root': root,
'up': update,
'update': update, 'update': update,
'url' : url, 'url' : url,
'watch-lock': watch_lock, 'watch-lock': watch_lock,
'users': users, 'users': users,
'binaries': binaries, 'binaries': binaries,
'lockable': lockable, 'lockable': lockable,
'st': status,
'stat': status,
'status': status, 'status': status,
} }