]> iEval git - app-zealc.git/blame_incremental - lib/App/Zealc.pm
Initial commit
[app-zealc.git] / lib / App / Zealc.pm
... / ...
CommitLineData
1package App::Zealc;
2
3use 5.014000;
4use strict;
5use warnings;
6
7our $VERSION = '0.000_001';
8
9use App::Cmd::Setup '-app';
10use parent qw/Class::Accessor::Fast/;
11__PACKAGE__->mk_accessors(qw/path zeal config verbose/);
12
13use Class::Method::Modifiers qw/before/;
14use Config::Auto;
15
16use File::Spec::Functions qw/catfile/;
17
18use Zeal;
19
20use constant DEFAULT_PATH => $ENV{HOME} ? catfile $ENV{HOME}, '.docsets' : '.docsets';
21
22sub allow_any_unambiguous_abbrev () { 1 }
23sub default_command { 'commands' } # Show usage when called without arguments
24
25sub global_opt_spec {
26 (['config|c=s' => 'Path to configuration file'],
27 ['path|p=s' => 'Path to docset directory',],
28 ['verbose|v!' => 'Print verbose debugging output'])
29}
30
31sub parse_config {
32 my ($cfg) = @_;
33 return Config::Auto::parse($cfg) if $cfg;
34 eval { Config::Auto::parse } or {}
35}
36
37before 'execute_command' => sub {
38 my ($self) = @_;
39 my %opts = %{$self->global_options};
40 my $config = parse_config $ENV{ZEALC_CONFIG} || $opts{config};
41 my %config = %$config;
42 my $path = $opts{path} || $config{path} || DEFAULT_PATH;
43 mkdir $path unless -d $path;
44
45 my $zeal = Zeal->new($path);
46 $self->path($path);
47 $self->zeal($zeal);
48 $self->config($config);
49 $self->verbose($opts{verbose} || $config{verbose})
50};
51
521;
53__END__
54
55=encoding utf-8
56
57=head1 NAME
58
59App::Zealc - command-line offline documentation browser for Dash/Zeal docsets
60
61=head1 SYNOPSIS
62
63 use App::Zealc;
64 App::Zealc->run;
65
66=head1 DESCRIPTION
67
68zealc is a command-line offline documentation browser inspired by
69L<Dash|http://kapeli.com/dash> and L<Zeal|http://zealdocs.org>. It
70uses Dash/Zeal format docsets via the L<Zeal> library.
71
72=head1 SEE ALSO
73
74L<zealc>, L<Zeal>
75
76=head1 AUTHOR
77
78Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
79
80=head1 COPYRIGHT AND LICENSE
81
82Copyright (C) 2015 by Marius Gavrilescu
83
84This library is free software; you can redistribute it and/or modify
85it under the same terms as Perl itself, either Perl version 5.20.1 or,
86at your option, any later version of Perl 5 you may have available.
87
88
89=cut
This page took 0.022828 seconds and 4 git commands to generate.