Skip to content

Commit

Permalink
[#39] Add confirm_install_ok function
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Galpin committed Jun 29, 2016
1 parent 478c806 commit 46d057f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion apt-vim
Expand Up @@ -584,13 +584,26 @@ class aptvim(object):
' is in your PATH'
report_fail(msg, confirm_continue=False, ASSUME_YES=self.ASSUME_YES)

def confirm_install_ok(self, install_requester, commands):
confirm_string = 'Package `' + install_requester + '` wants to run the following commands:\n'
command_string = ''
for command in commands:
command_string += command + '\n'
confirm_string += command_string + 'Is this ok?'

if self.ASSUME_YES or user_confirm(confirm_string, ASSUME_YES=self.ASSUME_YES):
return True
return False

def init(self):
self.verify_bin_in_path()
missing_deps = []
deps = self.VIM_CONFIG[GBL][DPND]
for dep in deps:
dep = Dependency.dict_to_dep(dep, ASSUME_YES=self.ASSUME_YES)
if not self.check_requirements([dep.name]):
if not self.check_requirements([dep.name]) and \
(len(dep.get_recipe(ASSUME_YES=self.ASSUME_YES)) > 0 and self.confirm_install_ok(dep.name, dep.get_recipe(ASSUME_YES=self.ASSUME_YES))):
print('Attempting to install `' + dep.name + '`')
if not self.exe_shell_commands(dep.get_recipe(ASSUME_YES=self.ASSUME_YES)):
missing_deps.append(dep.name)
return missing_deps
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Expand Up @@ -5,7 +5,7 @@ bin_string="export PATH=${PATH}:${HOME}/.vimpkg/bin"

# Download the apt-vim files
curl -fSsLo ${HOME}/apt-vim/apt-vim --create-dirs \
https://raw.githubusercontent.com/egalpin/apt-vim/39_bug_remove_sudo_dependence/apt-vim
https://raw.githubusercontent.com/egalpin/apt-vim/master/apt-vim

curl -fSsLo ${HOME}/apt-vim/vim_config.json \
https://raw.githubusercontent.com/egalpin/apt-vim/master/vim_config.json
Expand All @@ -29,7 +29,6 @@ already_present=false
for rc in bashrc zshrc bash_profile; do
if [ -s "$HOME/.$rc" ]; then
if grep -q "$bin_string" "$HOME/.$rc"; then
printf "== apt-vim PATH already exported in '~/.$rc'\n"
already_present=true
else
printf "\n$bin_string\n" >> "$HOME/.$rc"
Expand Down Expand Up @@ -60,6 +59,7 @@ python_result=$?

cd $start_dir

echo
if [ "$python_result" -ne 0 ]; then
echo "== Error:"
echo " Installation failed."
Expand Down

0 comments on commit 46d057f

Please sign in to comment.