jsvn: implement command aliases from configuration file
This commit is contained in:
parent
4d923cfadb
commit
fdae2a537c
12
jsvn
12
jsvn
@ -115,6 +115,17 @@ def get_config():
|
|||||||
% (pth, lineno, fn))
|
% (pth, lineno, fn))
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
def apply_aliases(config, argv):
|
||||||
|
if not argv[0] in config['aliases']:
|
||||||
|
return argv
|
||||||
|
alias = config['aliases'][argv[0]]
|
||||||
|
if type(alias) == str:
|
||||||
|
return [alias] + argv[1:]
|
||||||
|
elif type(alias) == list:
|
||||||
|
return alias + argv[1:]
|
||||||
|
sys.stderr.write('Unsupported type for alias "%s"\n' % alias)
|
||||||
|
return argv
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Utility Functions #
|
# Utility Functions #
|
||||||
###########################################################################
|
###########################################################################
|
||||||
@ -677,6 +688,7 @@ def main(argv):
|
|||||||
config = get_config()
|
config = get_config()
|
||||||
realsvn = findInPath('svn')
|
realsvn = findInPath('svn')
|
||||||
out = sys.stdout
|
out = sys.stdout
|
||||||
|
argv = apply_aliases(config, argv)
|
||||||
using_pager = False
|
using_pager = False
|
||||||
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']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user