]>
Commit | Line | Data |
---|---|---|
6c01e3e3 MG |
1 | package App::Zealc::Command::expand; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
6 | ||
7 | our $VERSION = '0.000_001'; | |
8 | ||
9 | use App::Zealc '-command'; | |
10 | ||
11 | sub usage_desc { "%c expand %o pattern"} | |
12 | ||
13 | sub opt_spec { | |
14 | (['family|f!', 'Include docset family in output']), | |
15 | } | |
16 | ||
17 | sub validate_args { | |
18 | my ($self, $opts, $args) = @_; | |
19 | my @args = @$args; | |
20 | $self->usage_error("No pattern specified") unless @args; | |
21 | $self->usage_error("Too many arguments") if @args > 1; | |
22 | } | |
23 | ||
24 | sub execute { | |
25 | my ($self, $opts, $args) = @_; | |
26 | my @results = sort { $a->name cmp $b->name } $self->app->zeal->query($args->[0]); | |
27 | exit 1 unless @results; | |
28 | say join "\n", map { | |
29 | my $family = $_->docset->family; | |
30 | $opts->{family} ? "$family:" . $_->name : $_->name | |
31 | } @results | |
32 | } | |
33 | ||
34 | 1; | |
35 | __END__ | |
36 | ||
37 | =encoding utf-8 | |
38 | ||
39 | =head1 NAME | |
40 | ||
41 | App::Zealc::Command::expand - list all documents that match a pattern | |
42 | ||
43 | =head1 SYNOPSIS | |
44 | ||
45 | zealc expand perlmo% | |
46 | # perlmod | |
47 | # perlmodinstall | |
48 | # perlmodlib | |
49 | # perlmodstyle | |
50 | ||
51 | zealc expand -f perl_os | |
52 | # perl:perldos | |
53 | # perl:perlvos | |
54 | ||
55 | =head1 DESCRIPTION | |
56 | ||
57 | The expand command lists all documents that match a case-insensitive | |
58 | SQL LIKE pattern. | |
59 | ||
60 | A SQL LIKE pattern is similar to a shell glob. The "%" character | |
61 | matches zero or more characters (like "*" in a shell glob or ".*" in a | |
62 | regex) and "_" matches exactly one character (like "?" in a shell glob | |
63 | or "." in a regex). Matching is case-insensitive. | |
64 | ||
65 | =head1 SEE ALSO | |
66 | ||
67 | L<zealc>, L<Zeal> | |
68 | ||
69 | =head1 AUTHOR | |
70 | ||
71 | Marius Gavrilescu, E<lt>marius@ieval.roE<gt> | |
72 | ||
73 | =head1 COPYRIGHT AND LICENSE | |
74 | ||
75 | Copyright (C) 2015 by Marius Gavrilescu | |
76 | ||
77 | This library is free software; you can redistribute it and/or modify | |
78 | it under the same terms as Perl itself, either Perl version 5.20.1 or, | |
79 | at your option, any later version of Perl 5 you may have available. | |
80 | ||
81 | ||
82 | =cut |