Debian Codegraph @

demos/demo_cmdline

raw
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use Getopt::Declare;
6
7 use vars qw($VERSION);
8 $VERSION = "1.00b";
9
10 my $config;
11
12 $config = Getopt::Declare->new( <<'EOCONFIG', [-CONFIG]);
13 [strict]
14 min = <n> Minimum value [required]
15 max = <n> Maximum value
16
17 EOCONFIG
18
19 print "min: ", $config->{min}{'<n>'}, "\n" if $config->{min};
20 print "max: ", $config->{max}{'<n>'}, "\n" if $config->{max};
21
22
23 my $specs = qq{
24 This is $0 version $VERSION
25
26 General options:
27
28 -e <f:i>..<t:i> Set expansion factor to specified range
29 [requires: <file>]
30 { print "k = [\$f..\$t]\n"; }
31
32 -e [<k:n>...] Set expansion factor to <k> (or 2 by default)
33 [required]
34 { \@k = (2) unless \@k; print "k = [", join(', ', \@k), "]\n"; }
35
36 -b <blen:i> Use byte length of <blen>
37 [excludes: -a +c]
38 { print "byte len: \$blen\n"; }
39
40 <file>... Process files [required] [implies: -a]
41 { print "files: \@file\n"; }
42
43 -a [<N:n>] Process all data [except item <N>]
44 { print "proc all"; print " except \$N" if \$N; print "\n"; }
45
46 -fab The fabulous option (is always required :-)
47 [required]
48 { defer { print "fabulous!\n" } }
49
50 File creation options:
51
52 +c <file> Create file [mutex: +c -a]
53 { print "create: \$file\n"; }
54
55 +d <file> Duplicate file [implies: -a and -b 8]
56 This is a second line
57 { print "dup (+d) \$file\n"; }
58
59 --dup <file> [ditto] (long form)
60
61 -how <N:i> Set height to <N> [repeatable]
62
63 Garbling options:
64
65 -g [<seed:i>] Garble output with optional seed [requires: +c]
66 { print "garbling with \$seed\n"; }
67
68 -i Case insensitive garbling [required]
69 { print "insensitive\n"; }
70 -s Case sensitive garbling
71 -w WaReZ m0De 6aRBL1N6
72
73 [mutex: -i -s -w]
74 };
75
76 my $args = Getopt::Declare->new($specs);
77
78 print "Unused:\n" if @ARGV;
79 foreach ( @ARGV )
80 {
81 print "\t[$_]\n";
82 }
83
84 #$args->debug();
85 #$args->usage();
86 __END__