Initial commit
[app-zealc.git] / lib / App / Zealc / Command / download.pm
CommitLineData
6c01e3e3
MG
1package App::Zealc::Command::download;
2
3use 5.014000;
4use strict;
5use warnings;
6
7our $VERSION = '0.000_001';
8
9use App::Zealc '-command';
10
11use File::Spec::Functions qw/rel2abs/;
12
13use Term::ANSIColor qw/:constants/;
14use Term::FormatColumns qw/format_columns/;
15use Zeal::Feed;
16
17use constant FEEDS => [qw/NET_Framework ActionScript ColdFusion Akka Android AngularJS Ansible Apache_HTTP_Server Appcelerator_Titanium AppleScript Arduino AWS_JavaScript BackboneJS Bash Boost Bootstrap_2 Bootstrap_3 Bourbon C CakePHP Cappuccino Chai Chef Clojure CMake Cocos2D Cocos3D CodeIgniter CoffeeScript Common_Lisp Compass Cordova Corona CSS D3JS Dart Django Dojo DOM Drupal_7 Drupal_8 ElasticSearch Elixir Emacs_Lisp EmberJS Emmet Erlang Express ExpressionEngine ExtJS Flask Font_Awesome Foundation Git GLib Go Grails Groovy Groovy_JDK Grunt Haml Haskell HTML iOS Jade Jasmine Java_EE6 Java_EE7 Java_SE6 Java_SE7 Java_SE8 JavaFX JavaScript Joomla jQuery jQuery_Mobile jQuery_UI KnockoutJS Kobold2D LaTeX Laravel Less Linux_Man_Pages Mac_OS_X Man_Pages MarionetteJS Markdown Meteor MomentJS MongoDB Mongoose Mono MooTools MySQL Neat Nginx NodeJS NumPy OCaml OpenCV_C OpenCV_Java OpenCV_Python OpenGL_2 OpenGL_3 OpenGL_4 Perl PhoneGap PHP PHPUnit Play_Java Play_Scala PostgreSQL Processing PrototypeJS Puppet Python_2 Python_3 Qt_4 Qt_5 R Redis RequireJS Ruby Ruby_2 Ruby_on_Rails_3 Ruby_on_Rails_4 RubyMotion Rust SaltStack Sass Scala SciPy Sencha_Touch Sinon Smarty Sparrow Spring_Framework SproutCore SQLAlchemy SQLite Statamic Stylus SVG Swift Symfony Tcl Tornado Twig Twisted TYPO3 UnderscoreJS Unity_3D Vagrant Vim VMware_vSphere WordPress Xamarin Xojo XSLT XUL Yii YUI Zend_Framework_1 Zend_Framework_2 ZeptoJS/];
18
19my %feeds = map { y/A-Z_/a-z-/r => $_ } @{FEEDS()};
20
21sub usage_desc { "%c download %o\n%c download %o DOCSET\n%c download URL_TO_FEED" }
22
23sub validate_args {
24 my ($self, $opts, $args) = @_;
25 my @args = @$args;
26 $self->usage_error("Too many arguments") if @args > 1;
27}
28
29sub _show_docset {
30 my ($file) = @_;
31 return $_ unless -d $file;
32 return BOLD . "$_*" . RESET if -t select;
33 return "$_*";
34}
35
36sub execute {
37 my ($self, $opts, $args) = @_;
38 my ($name) = @$args;
39 if (!$name) {
40 my @feeds = map {
41 my $fname = $feeds{$_} =~ y/_/ /r;
42 my $file = rel2abs "$fname.docset", $self->app->path;
43 _show_docset $file
44 } sort keys %feeds;
45 print format_columns @feeds;
46 } else {
47 my $feed = Zeal::Feed->new(exists $feeds{$name} ? "http://kapeli.com/feeds/$feeds{$name}.xml" : $name);
48 say "Downloading $feeds{$name} version ", $feed->version, ' from ', $feed->url;
49 $feed->download($self->app->path);
50 }
51}
52
531;
54__END__
55
56=encoding utf-8
57
58=head1 NAME
59
60App::Zealc::Command::download - view available docsets and download them
61
62=head1 SYNOPSIS
63
64 zealc download
65 # <list of docsets>
66
67 zealc download latex
68 # Downloading LaTeX version /1 from http://london3.kapeli.com/feeds/LaTeX.tgz
69
70 zealc download http://kapeli.com/feeds/LaTeX.xml
71 # Downloading LaTeX version /1 from http://london3.kapeli.com/feeds/LaTeX.tgz
72
73=head1 DESCRIPTION
74
75When invoked with no arguments, the download command displays a list
76of known Dash docsets. The installed docsets have a * after their
77name.
78
79When invoked with an argument from the list of known Dash docsets it
80downloads that docset.
81
82When invoked with an argument not from the list of known Dash docsets
83it assumes the argument is a link to a L<Zeal::Feed> and downloads the
84docset described by the feed.
85
86=head1 SEE ALSO
87
88L<zealc>, L<Zeal>
89
90=head1 AUTHOR
91
92Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
93
94=head1 COPYRIGHT AND LICENSE
95
96Copyright (C) 2015 by Marius Gavrilescu
97
98This library is free software; you can redistribute it and/or modify
99it under the same terms as Perl itself, either Perl version 5.20.1 or,
100at your option, any later version of Perl 5 you may have available.
101
102
103=cut
This page took 0.014967 seconds and 4 git commands to generate.