move logging to install

This commit is contained in:
gmarik 2011-03-19 15:21:05 -05:00
parent dd5b44db2c
commit c23ccfabda

View File

@ -3,17 +3,24 @@ func! vundle#installer#install(bang, ...)
let bundles = (a:1 == '') ? let bundles = (a:1 == '') ?
\ s:reload_bundles() : \ s:reload_bundles() :
\ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})') \ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})')
call map(copy(bundles), 's:install(a:bang, v:val)')
call vundle#installer#helptags(bundles) let installed = s:install(a:bang, bundles)
redraw!
let help_dirs = vundle#installer#helptags(bundles)
call vundle#config#require(bundles)
call s:log('Installed bundles: '.join(len(installed) > 0 ? map(installed, 'v:val.name') : 'none',','))
if len(help_dirs) > 0
call s:log('Helptags: done. '.len(help_dirs).' bundles processed')
endif
endf endf
func! vundle#installer#helptags(bundles) func! vundle#installer#helptags(bundles)
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath()') let bundle_dirs = map(copy(a:bundles),'v:val.rtpath()')
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)') let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')
call map(copy(help_dirs), 's:helptags(v:val)') call map(copy(help_dirs), 's:helptags(v:val)')
if len(help_dirs) > 0 return help_dirs
call s:log('Helptags: done. '.len(help_dirs).' bundles processed')
endif
endf endf
func! vundle#installer#clean(bang) func! vundle#installer#clean(bang)
@ -21,6 +28,7 @@ func! vundle#installer#clean(bang)
let all_dirs = split(globpath(g:bundle_dir, '*'), "\n") let all_dirs = split(globpath(g:bundle_dir, '*'), "\n")
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)') let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
if (!empty(x_dirs)) if (!empty(x_dirs))
" TODO: improve message
if (a:bang || input('Are you sure you want to remove '.len(x_dirs).' bundles?') =~? 'y') if (a:bang || input('Are you sure you want to remove '.len(x_dirs).' bundles?') =~? 'y')
exec '!rm -rf '.join(map(x_dirs, 'shellescape(v:val)'), ' ') exec '!rm -rf '.join(map(x_dirs, 'shellescape(v:val)'), ' ')
endif endif
@ -55,19 +63,11 @@ func! s:sync(bang, bundle)
return 1 return 1
endf endf
func! s:install(bang, bundle) func! s:install(bang, bundles)
let synced = s:sync(a:bang, a:bundle) return filter(copy(a:bundles), 's:sync(a:bang, v:val)')
call s:log(a:bundle.name.' '.(synced ? '': ' already').' installed')
call vundle#config#require(a:bundle)
endf endf
" TODO: make it pause after output in console mode " TODO: make it pause after output in console mode
func! s:log(msg) func! s:log(msg)
if has('gui_running') echo a:msg
echo a:msg
else
" console vim requires to hit ENTER after each !cmd with stdout output
" workaround
silent exec '! echo '.a:msg.' >&2| cat >/dev/null'
endif
endf endf