summaryrefslogtreecommitdiff
path: root/support/latexindent/LatexIndent/LogFile.pm
diff options
context:
space:
mode:
Diffstat (limited to 'support/latexindent/LatexIndent/LogFile.pm')
-rw-r--r--support/latexindent/LatexIndent/LogFile.pm67
1 files changed, 62 insertions, 5 deletions
diff --git a/support/latexindent/LatexIndent/LogFile.pm b/support/latexindent/LatexIndent/LogFile.pm
index 692bfddbdb..fa6df78828 100644
--- a/support/latexindent/LatexIndent/LogFile.pm
+++ b/support/latexindent/LatexIndent/LogFile.pm
@@ -61,6 +61,9 @@ usage: latexindent.pl [options] [file]
latexindent.pl -o=outputfile.tex myfile.tex
-w, --overwrite
overwrite the current file; a backup will be made, but still be careful
+ -wd, --overwriteIfDifferent
+ overwrite the current file IF the indented text is different from original;
+ a backup will be made, but still be careful
-s, --silent
silent mode: no output will be given to the terminal
-t, --trace
@@ -103,6 +106,9 @@ usage: latexindent.pl [options] [file]
only operate on selected lines; sample usage:
latexindent.pl --lines 3-5 myfile.tex
latexindent.pl --lines 3-5,7-10 myfile.tex
+ --GCString
+ loads the Unicode::GCString module for the align-at-ampersand routine
+ Note: this requires the Unicode::GCString module to be installed on your system
ENDQUOTE
;
exit(0);
@@ -110,6 +116,7 @@ ENDQUOTE
# if we've made it this far, the processing of switches and logging begins
my $self = shift;
+ my @fileNames = @{$_[0]};
$logger = LatexIndent::Logger->new();
@@ -134,7 +141,16 @@ ENDQUOTE
$logger->info($time);
if (${$self}{fileName} ne "-"){
- $logger->info("Filename: ${$self}{fileName}");
+ # multiple filenames or not
+ if ( (scalar (@fileNames)) >1 ){
+ $logger->info("Filenames:");
+ foreach (@fileNames) {
+ $logger->info(" $_");
+ }
+ $logger->info("total number of files: ".(scalar (@fileNames)));
+ } else {
+ $logger->info("Filename: ${$self}{fileName}");
+ }
} else {
$logger->info("Reading input from STDIN");
if (-t STDIN) {
@@ -155,7 +171,8 @@ ENDQUOTE
$logger->info("-tt|--ttrace: TTrace mode active (you have used either -tt or --ttrace)") if($switches{ttrace});
$logger->info("-s|--silent: Silent mode active (you have used either -s or --silent)") if($switches{silentMode});
$logger->info("-d|--onlydefault: Only defaultSettings.yaml will be used (you have used either -d or --onlydefault)") if($switches{onlyDefault});
- $logger->info("-w|--overwrite: Overwrite mode active, will make a back up of ${$self}{fileName} first") if($switches{overwrite});
+ $logger->info("-w|--overwrite: Overwrite mode active, will make a back up before overwriting") if($switches{overwrite});
+ $logger->info("-wd|--overwriteIfDifferent: will overwrite ONLY if indented text is different") if($switches{overwriteIfDifferent});
$logger->info("-l|--localSettings: Read localSettings YAML file") if($switches{readLocalSettings});
$logger->info("-y|--yaml: YAML settings specified via command line") if($switches{yaml});
$logger->info("-o|--outputfile: output to file") if($switches{outputToFile});
@@ -167,18 +184,58 @@ ENDQUOTE
$logger->info("-k|--check mode: will exit with 0 if document body unchanged, 1 if changed") if($switches{check});
$logger->info("-kv|--check mode verbose: as in check mode, but outputs diff to screen") if($switches{checkverbose});
$logger->info("-n|--lines mode: will only operate on specific lines $switches{lines}") if($switches{lines});
+ $logger->info("--GCString switch active, loading Unicode::GCString module") if($switches{GCString});
# check if overwrite and outputfile are active similtaneously
if($switches{overwrite} and $switches{outputToFile}){
- $logger->info("Options check, -w and -o specified\nYou have called latexindent.pl with both -o and -w\noutput to file) will take priority, and -w (over write) will be ignored");
+ $logger->info("*Options check: -w and -o specified");
+ $logger->info("You have called latexindent.pl with both -o and -w");
+ $logger->info("The -o switch will take priority, and -w (overwrite) will be ignored");
+ $switches{overwrite}=0;
+ }
+
+ # check if overwrite and outputfile are active similtaneously
+ if($switches{overwrite} and $switches{overwriteIfDifferent}){
+ $logger->info("*Options check: -w and -wd specified");
+ $logger->info("You have called latexindent.pl with both -w and -wd.");
+ $logger->info("The -wd switch will take priority, and -w (overwrite) will be ignored");
$switches{overwrite}=0;
}
- $logger->info("*Directory for backup files and $logfileName: ${$self}{cruftDirectory}");
+ # check if overwriteIfDifferent and outputfile are active similtaneously
+ if($switches{overwriteIfDifferent} and $switches{outputToFile}){
+ $logger->info("*Options check: -wd and -o specified");
+ $logger->info("You have called latexindent.pl with both -o and -wd");
+ $logger->info("The -o switch will take priority, and -wd (overwriteIfDifferent) will be ignored");
+ $switches{overwriteIfDifferent}=0;
+ }
+
+ # multiple files with the -o switch needs care
+ #
+ # example
+ #
+ # latexindent.pl *.tex -o myfile.tex
+ #
+ # would result in only the final file being written to myfile.tex
+ #
+ # So, if -o switch does *not* match having a + symbol at the beginning, then
+ # we ignore it, and turn it off
+ #
+ if ( (scalar @fileNames>1) and $switches{outputToFile} and ($switches{outputToFile} !~ m/^h*\+/) ){
+ $logger->warn("*-o switch specified as single file, but multiple files given as input");
+ $logger->warn("ignoring your specification -o $switches{outputToFile}");
+ $logger->warn("perhaps you migh specify it using, for example, -o=++ or -o=+myoutput");
+ $switches{outputToFile} =0;
+ }
+
+ $logger->info("*Directory for backup files and $logfileName:");
+ $logger->info("${$self}{cruftDirectory}");
# output location of modules
if($FindBin::Script eq 'latexindent.pl' or ($FindBin::Script eq 'latexindent.exe' and $switches{trace} )) {
- my @listOfModules = ('FindBin', 'YAML::Tiny', 'File::Copy', 'File::Basename', 'Getopt::Long','File::HomeDir','Unicode::GCString');
+ my @listOfModules = ('FindBin', 'YAML::Tiny', 'File::Copy', 'File::Basename', 'Getopt::Long','File::HomeDir');
+ push(@listOfModules,'Unicode::GCString') if $switches{GCString};
+
$logger->info("*Perl modules are being loaded from the following directories:");
foreach my $moduleName (@listOfModules) {
(my $file = $moduleName) =~ s|::|/|g;