-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsxml2xml.pl6
executable file
·37 lines (32 loc) · 989 Bytes
/
sxml2xml.pl6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env perl6
#
use v6;
use SemiXML::Sxml;
# Allow switches after positionals. Pinched from an older panda version. Now
# it is possible to make the sxml file executable with the path of this
# program.
#
# When switches are given in the Unix hash-bang command the text after the
# command is one string. This must be split first and pushed separately.
my @a;
for grep( /^ '--'/, @*ARGS) -> $a {
for $a.split( /\s+ <?before '--'>/ ) {
@a.push: $^a;
}
}
@*ARGS = ( |@a, |grep( /^ <-[-]>/, @*ARGS));
#for @*ARGS {
# note "A: $^a";
#}
#-------------------------------------------------------------------------------
#TODO doc
sub MAIN (
Str $filename, Str :$in = 'xml', Str :$out = 'xml',
Bool :$force = False, Bool :$trace = False, Bool :$keep = False,
Bool :$raw = False, Bool :$exec = True, Bool :$frag = False
) {
my SemiXML::Sxml $x .= new(:refine([ $in, $out]));
$x.save if $x.parse(
:$filename, :$raw, :$force, :$trace, :$keep, :$exec, :$frag
);
}