Last active
December 27, 2015 18:39
-
-
Save rhysd/7371054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" https://github.com/vim-jp/vital.vim | |
let s:OptionParser = vital#of('vital').import('OptionParser') | |
let s:parser = s:OptionParser.new() | |
call s:parser.on('--themselves', '-t', '') | |
call s:parser.on('--ourselves', '-o', '') | |
call s:parser.on('--[no-]ask', '') | |
call s:parser.on('--file=FILE', '') | |
command! -nargs=* -range=% -bang ResolveConflicts | |
\ call <SID>resolve_conflicts( | |
\ s:parser.parse(<q-args>, [<line1>, <line2>], <q-bang>) | |
\ ) | |
function! s:resolve_conflicts(opts) | |
if has_key(a:opts, 'themselves') | |
" --themselves が指定されたときの処理 | |
endif | |
if has_key(a:opts, 'ourselves') | |
" --ourselves が指定されたときの処理 | |
endif | |
if has_key(a:opts, 'ask') | |
" --ask または --no-ask が指定されたときの処理 | |
endif | |
if has_key(a:opts, 'file') | |
" --file に値が指定されたときの処理" | |
endif | |
if has_key(a:opts, '__bang__') | |
" コマンドに ! が付けられた時の処理 | |
endif | |
if a:opts.__unknown_args__ != [] | |
" 指定外のオプションが付けられたときの処理 | |
endif | |
endfunction | |
" execute! | |
1,10ResolveConflicts! -t --no-ask poyo | |
ResolveConflicts --help |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment