Provide interface for subcommands to set execution options

This commit is contained in:
Tim Pope
2020-01-10 19:23:45 -05:00
parent 394c925381
commit 5fe99dc5df

View File

@@ -2177,13 +2177,15 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
if exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' if exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help'
try try
exe s:DirCheck(dir) exe s:DirCheck(dir)
let result = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, args[1:-1]) let opts = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, args[1:-1])
if type(result) == type('') if type(opts) == type('')
return 'exe ' . string(result) . after return 'exe ' . string(opts) . after
endif endif
catch /^fugitive:/ catch /^fugitive:/
return 'echoerr ' . string(v:exception) return 'echoerr ' . string(v:exception)
endtry endtry
else
let opts = {}
endif endif
if a:bang || args[0] =~# '^-P$\|^--no-pager$\|diff\%(tool\)\@!\|log\|^show$' || if a:bang || args[0] =~# '^-P$\|^--no-pager$\|diff\%(tool\)\@!\|log\|^show$' ||
\ (args[0] ==# 'stash' && get(args, 1, '') ==# 'show') || \ (args[0] ==# 'stash' && get(args, 1, '') ==# 'show') ||
@@ -3896,7 +3898,7 @@ function! s:ToolStream(dir, line1, line2, range, bang, mods, args, state, title)
endif endif
let arg = argv[i] let arg = argv[i]
if arg =~# '^-t$\|^--tool=\|^--tool-help$\|^--help$' if arg =~# '^-t$\|^--tool=\|^--tool-help$\|^--help$'
return -1 return {}
elseif arg =~# '^-y$\|^--no-prompt$' elseif arg =~# '^-y$\|^--no-prompt$'
let prompt = 0 let prompt = 0
call remove(argv, i) call remove(argv, i)