diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/latexindent/latexindent-module-installer.pl |
Initial commit
Diffstat (limited to 'support/latexindent/latexindent-module-installer.pl')
-rwxr-xr-x | support/latexindent/latexindent-module-installer.pl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/support/latexindent/latexindent-module-installer.pl b/support/latexindent/latexindent-module-installer.pl new file mode 100755 index 0000000000..e45fdcbe73 --- /dev/null +++ b/support/latexindent/latexindent-module-installer.pl @@ -0,0 +1,49 @@ +#!/usr/bin/env perl +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# See http://www.gnu.org/licenses/. +# +# Chris Hughes, 2017 +# +# For all communication, please visit: https://github.com/cmhughes/latexindent.pl + +use strict; +use warnings; + +print ("============\nlatexindent.pl module installer\n============\n"); +print ("Would you like to run the following commands?\n"); +my @modulesToInstall = ("cpanm YAML::Tiny","cpanm File::HomeDir","cpanm Unicode::GCString","cpanm Log::Log4perl","cpanm Log::Dispatch"); +foreach (@modulesToInstall) { + print $_,"\n"; +} +if (prompt_yn("Press Y to run the above commands")){ + foreach (@modulesToInstall) { + system($_); + } +} else { + print "Not installing modules\n"; +} +exit; + +# reference: https://stackoverflow.com/questions/18103501/prompting-multiple-questions-to-user-yes-no-file-name-input +sub prompt { + my ($query) = @_; # take a prompt string as argument + local $| = 1; # activate autoflush to immediately show the prompt + print $query; + chomp(my $answer = <STDIN>); + return $answer; +} + +sub prompt_yn { + my ($query) = @_; + my $answer = prompt("$query (Y/N): "); + return lc($answer) eq 'y'; +} |