@@ -37,6 +37,8 @@ my %CMDLINE_OPTS = (
37
37
# They are listed in alphabetical order by option name,
38
38
# lowercase before upper, although the code does not require that order.
39
39
40
+ # BACKEND => ['b', '|backend=s'], # TODO
41
+
40
42
# DUMP_VARS => ['d', '|dump-variables', false],
41
43
# DEBUG => ['D','|debug', false],
42
44
EVAL => [' e' ,' |source=s@' , $dr_save_source ],
@@ -144,10 +146,15 @@ sub Main {
144
146
return 0;
145
147
}
146
148
147
- # Treat the first non-option arg as a script if appropriate
149
+ # Treat the first non-option arg as a script file if it exists
150
+ # and is readable, otherwise as axk source.
148
151
unless (@{$opts {SOURCES }}) {
149
152
die " No scripts to run" unless @$lrArgs ;
150
- push @{$opts {SOURCES }}, [false, shift @$lrArgs ];
153
+ my $option = shift @$lrArgs ;
154
+ push @{$opts {SOURCES }}, [
155
+ -r $option && (-f $option || -l $option ),
156
+ $option
157
+ ];
151
158
}
152
159
153
160
my $core = XML::Axk::Core-> new(\%opts );
@@ -192,18 +199,24 @@ XML::Axk::App - awk-like XML processor, command-line interface
192
199
193
200
=head1 USAGE
194
201
195
- axk [options] [--] [script] [ input filename(s) ]
202
+ axk [options] [--] [input filename or script ]
196
203
197
204
=head1 INPUTS
198
205
199
206
A filename of C<- > represents standard input. To actually process a file
200
207
named C<- > , you will need to use shell redirection (e.g., C<< axk < - >>).
201
208
Standard input is the default if no input filenames are given.
202
209
203
- The first non-option argument is a program if no -e or -f are given.
210
+ The first non-option argument is used for program text if no -e or -f
211
+ are given. If that argument names a readable regular file or symlink,
212
+ an axk program will be loaded from that file. Otherwise, that argument
213
+ is used as an axk program directly.
214
+
204
215
The script language version for a -e will default to the latest if the text
205
216
on the command line doesn't specify a language version.
206
217
218
+ # TODO make -L and -B apply to following -e's
219
+
207
220
=head1 OPTIONS
208
221
209
222
=over
0 commit comments