Skip to content

Commit

Permalink
eolang (31oct24)
Browse files Browse the repository at this point in the history
git-svn-id: svn://tug.org/texlive/trunk/Build/source@72724 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
kberry committed Oct 31, 2024
1 parent 084f93b commit c4ac4d0
Showing 1 changed file with 6 additions and 42 deletions.
48 changes: 6 additions & 42 deletions texk/texlive/linked_scripts/eolang/eolang.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# (The MIT License)
#
# Copyright (c) 2022-2024 Yegor Bugayenko
# Copyright (c) 2021-2024 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
Expand All @@ -21,66 +21,30 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# 2024-02-14 0.18.1
# 0000-00-00 0.18.2
package eolang;

use warnings;
use strict;
use lib('.');
use tools;
use File::Basename;

# Hash of incoming command line arguments.
my %args = map { $_ => 1 } @ARGV;

# Read file content.
sub readfile {
my ($path) = @_;
open(my $h, '<', $path) or die('Cannot open file: ' . $path);
my $content; { local $/; $content = <$h>; }
return $content;
}

# Save content to file.
sub savefile {
my ($path, $content) = @_;
open(my $f, '>', $path) or error('Cannot open file for writing: ' . $path);
print $f $content;
close($f);
my $size = -s $path;
info("File saved to '$path' ($size bytes)");
}

# Print INFO message to the console.
sub info {
my ($txt) = @_;
print $txt . "\n";
}

# Print DEBUG message to the console.
sub debug {
my ($txt) = @_;
if (exists $args{'--verbose'}) {
print $txt . "\n";
}
}

# Print ERROR message to the console.
sub error {
my ($txt) = @_;
print STDERR $txt . "\n";
}

if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) {
info("This script helps embedding \\phiquation and \\phiq into .tex document\n\n" .
"Usage:\n" .
" eolang [<options>] <.tex file path>\n\n" .
" eolang [<options>] <.tex input file path> <.tex output file path>\n\n" .
"Options:\n" .
" -v, --version Print the current version of the tool and exit\n" .
" -?, --help Print this help screen\n" .
" --verbose Print all possible debugging information\n" .
" --tmpdir=path Temp directory with .tex files ('_eolang' by default)\n\n" .
"If any issues, report to GitHub: https://github.com/yegor256/bibcop");
} elsif (exists $args{'--version'} or exists $args{'-v'}) {
info('0.18.1 2024-02-14');
info('0.18.2 0000-00-00');
} else {
my ($src, $target) = grep { not($_ =~ /^-.*$/) } @ARGV;
if (not $src) {
Expand Down

0 comments on commit c4ac4d0

Please sign in to comment.