]
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
hex-describe rule --help |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Prints the random results of rules. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 OPTIONS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
C<--help> prints the man page. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
C<--table> specifies the table to load. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Without C<--table>, print all the tables there are. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
C<--rule> specifies the rule to use. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
C<--text> specifies the text to use (with rules in square brackets). |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Without C<--rule> or C<--text>, print all the rules there are. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
C<--limit> limits the output to a certain number of entries. The default is 10. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
C<--separator> changes the separator between entries. The default is two |
|
47
|
|
|
|
|
|
|
newlines, three dashes, and two newlines ("\n\n---\n\n"). |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Find all orc related rules: |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
C |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Print an orc tribe: |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
C |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Print ten orc names: |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
C
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package Game::HexDescribe::Command::rule; |
|
66
|
|
|
|
|
|
|
|
|
67
|
4
|
|
|
4
|
|
93830
|
use Modern::Perl '2018'; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
50
|
|
|
68
|
4
|
|
|
4
|
|
1228
|
use Mojo::Base 'Mojolicious::Command'; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
36
|
|
|
69
|
4
|
|
|
4
|
|
2185
|
use Pod::Simple::Text; |
|
|
4
|
|
|
|
|
12572
|
|
|
|
4
|
|
|
|
|
160
|
|
|
70
|
4
|
|
|
4
|
|
29
|
use Getopt::Long qw(GetOptionsFromArray); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
33
|
|
|
71
|
4
|
|
|
4
|
|
592
|
use Game::HexDescribe::Utils qw(markdown describe_text parse_table load_table list_tables); |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
205
|
|
|
72
|
4
|
|
|
4
|
|
17
|
use Role::Tiny; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
43
|
|
|
73
|
|
|
|
|
|
|
binmode(STDOUT, ':utf8'); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has description => 'Print the output of a rule to STDOUT'; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has usage => sub { my $self = shift; $self->extract_usage }; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub run { |
|
80
|
4
|
|
|
4
|
1
|
485
|
my ($self, @args) = @_; |
|
81
|
4
|
|
|
|
|
8
|
my ($help, $table, $rule, $text, $limit, $separator); |
|
82
|
4
|
|
|
|
|
23
|
GetOptionsFromArray ( |
|
83
|
|
|
|
|
|
|
\@args, |
|
84
|
|
|
|
|
|
|
"help" => \$help, |
|
85
|
|
|
|
|
|
|
"table=s" => \$table, |
|
86
|
|
|
|
|
|
|
"rule=s" => \$rule, |
|
87
|
|
|
|
|
|
|
"text=s" => \$text, |
|
88
|
|
|
|
|
|
|
"limit=i" => \$limit, |
|
89
|
|
|
|
|
|
|
"separator=s" => \$separator); |
|
90
|
4
|
50
|
|
|
|
3911
|
if ($help) { |
|
91
|
0
|
|
|
|
|
0
|
seek(DATA, 0, 0); # read from this file |
|
92
|
0
|
|
|
|
|
0
|
my $parser = Pod::Simple::Text->new(); |
|
93
|
0
|
|
|
|
|
0
|
$parser->output_fh(*STDOUT); |
|
94
|
0
|
|
|
|
|
0
|
$parser->parse_lines(); |
|
95
|
0
|
|
|
|
|
0
|
return 1; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
4
|
|
|
|
|
45
|
my $dir = $self->app->config('contrib'); |
|
98
|
4
|
50
|
|
|
|
129
|
if (not $table) { |
|
99
|
0
|
|
|
|
|
0
|
say for list_tables($dir); |
|
100
|
0
|
|
|
|
|
0
|
return 1; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
4
|
50
|
66
|
|
|
17
|
if (not $rule and not $text) { |
|
103
|
0
|
|
|
|
|
0
|
say for keys %{parse_table(load_table($table, $dir))}; |
|
|
0
|
|
|
|
|
0
|
|
|
104
|
0
|
|
|
|
|
0
|
return 1; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
4
|
|
|
|
|
19
|
my $data = parse_table(load_table($table, $dir)); |
|
107
|
4
|
|
50
|
|
|
652
|
$text //= "[$rule]\n" x ($limit || 10); |
|
|
|
|
66
|
|
|
|
|
|
108
|
4
|
|
|
|
|
41
|
say join("\n", markdown(describe_text($text, $data), $separator)); |
|
109
|
4
|
|
|
|
|
61454
|
1; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__DATA__ |