Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
updated command example
  • Loading branch information
kraih committed Jan 7, 2012
1 parent d9aa0e8 commit 5739bfe
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 105 deletions.
8 changes: 3 additions & 5 deletions lib/Mojo/Command.pm
Expand Up @@ -310,16 +310,14 @@ Mojo::Command - Command base class
use Getopt::Long 'GetOptions';
# Short description
has description => <<'EOF';
My first Mojo command.
EOF
has description => "My first Mojo command.\n";
# Short usage message
has usage => <<"EOF";
usage: $0 mycommand [OPTIONS]
These options are available:
--something Does something.
-s, --something Does something.
EOF
# <suitable Futurama quote here>
Expand All @@ -328,7 +326,7 @@ Mojo::Command - Command base class
# Handle options
local @ARGV = @_;
GetOptions('something' => sub { $something = 1 });
GetOptions('s|something' => sub { $something = 1 });
# Magic here! :)
}
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojolicious/Command/cgi.pm
@@ -1,13 +1,11 @@
package Mojolicious::Command::cgi;
use Mojo::Base 'Mojo::Command';

use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;
use Mojo::Server::CGI;

has description => <<'EOF';
Start application with CGI.
EOF
has usage => <<"EOF";
has description => "Start application with CGI.\n";
has usage => <<"EOF";
usage: $0 cgi [OPTIONS]
These options are available:
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojolicious/Command/cpanify.pm
Expand Up @@ -2,13 +2,11 @@ package Mojolicious::Command::cpanify;
use Mojo::Base 'Mojo::Command';

use File::Basename 'basename';
use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;
use Mojo::UserAgent;

has description => <<'EOF';
Upload distribution to CPAN.
EOF
has usage => <<"EOF";
has description => "Upload distribution to CPAN.\n";
has usage => <<"EOF";
usage: $0 cpanify [OPTIONS] [FILE]
mojo cpanify -u sri -p secr3t Mojolicious-Plugin-MyPlugin-0.01.tar.gz
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojolicious/Command/daemon.pm
@@ -1,13 +1,11 @@
package Mojolicious::Command::daemon;
use Mojo::Base 'Mojo::Command';

use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;
use Mojo::Server::Daemon;

has description => <<'EOF';
Start application with HTTP 1.1 and WebSocket server.
EOF
has usage => <<"EOF";
has description => "Start application with HTTP 1.1 and WebSocket server.\n";
has usage => <<"EOF";
usage: $0 daemon [OPTIONS]
These options are available:
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojolicious/Command/eval.pm
@@ -1,12 +1,10 @@
package Mojolicious::Command::eval;
use Mojo::Base 'Mojo::Command';

use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;

has description => <<'EOF';
Run code against application.
EOF
has usage => <<"EOF";
has description => "Run code against application.\n";
has usage => <<"EOF";
usage: $0 eval [OPTIONS] CODE
mojo eval 'say app->ua->get("/")->res->body'
Expand Down
10 changes: 3 additions & 7 deletions lib/Mojolicious/Command/generate.pm
Expand Up @@ -2,10 +2,8 @@ package Mojolicious::Command::generate;
use Mojo::Base 'Mojolicious::Commands';

# "Ah, nothing like a warm fire and a SuperSoaker of fine cognac."
has description => <<'EOF';
Generate files and directories from templates.
EOF
has hint => <<"EOF";
has description => "Generate files and directories from templates.\n";
has hint => <<"EOF";
See '$0 generate help GENERATOR' for more information on a specific generator.
EOF
Expand All @@ -16,9 +14,7 @@ These generators are currently available:
EOF
has namespaces =>
sub { [qw/Mojolicious::Command::generate Mojo::Command::generate/] };
has usage => <<"EOF";
usage: $0 generate GENERATOR [OPTIONS]
EOF
has usage => "usage: $0 generate GENERATOR [OPTIONS]\n";

1;
__END__
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Command/generate/app.pm
@@ -1,12 +1,8 @@
package Mojolicious::Command::generate::app;
use Mojo::Base 'Mojo::Command';

has description => <<'EOF';
Generate Mojolicious application directory structure.
EOF
has usage => <<"EOF";
usage: $0 generate app [CLASS]
EOF
has description => "Generate Mojolicious application directory structure.\n";
has usage => "usage: $0 generate app [CLASS]\n";

# "I say, you've damaged our servants quarters... and our servants."
sub run {
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Command/generate/gitignore.pm
@@ -1,12 +1,8 @@
package Mojolicious::Command::generate::gitignore;
use Mojo::Base 'Mojo::Command';

has description => <<'EOF';
Generate ".gitignore".
EOF
has usage => <<"EOF";
usage: $0 generate gitignore
EOF
has description => qq/Generate ".gitignore".\n/;
has usage => "usage: $0 generate gitignore\n";

# "I want to see the edge of the universe.
# Ooh, that sounds cool.
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Command/generate/hypnotoad.pm
@@ -1,12 +1,8 @@
package Mojolicious::Command::generate::hypnotoad;
use Mojo::Base 'Mojo::Command';

has description => <<'EOF';
Generate "hypnotoad.conf".
EOF
has usage => <<"EOF";
usage: $0 generate hypnotoad
EOF
has description => qq/Generate "hypnotoad.conf".\n/;
has usage => "usage: $0 generate hypnotoad\n";

# "Oh no! Can we switch back using four or more bodies?
# I'm not sure. I'm afraid we need to use... MATH."
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Command/generate/lite_app.pm
@@ -1,12 +1,8 @@
package Mojolicious::Command::generate::lite_app;
use Mojo::Base 'Mojo::Command';

has description => <<'EOF';
Generate Mojolicious::Lite application.
EOF
has usage => <<"EOF";
usage: $0 generate lite_app [NAME]
EOF
has description => "Generate Mojolicious::Lite application.\n";
has usage => "usage: $0 generate lite_app [NAME]\n";

# "As a scientist,
# I can assure you that we did in fact evolve from filthy monkey-men."
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Command/generate/makefile.pm
@@ -1,12 +1,8 @@
package Mojolicious::Command::generate::makefile;
use Mojo::Base 'Mojo::Command';

has description => <<'EOF';
Generate "Makefile.PL".
EOF
has usage => <<"EOF";
usage: $0 generate makefile
EOF
has description => qq/Generate "Makefile.PL".\n/;
has usage => "usage: $0 generate makefile\n";

# "If we don't go back there and make that event happen,
# the entire universe will be destroyed...
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Command/generate/plugin.pm
Expand Up @@ -4,12 +4,8 @@ use Mojo::Base 'Mojo::Command';
use Mojo::Util 'camelize';

# "You know Santa may have killed Scruffy, but he makes a good point."
has description => <<'EOF';
Generate Mojolicious plugin directory structure.
EOF
has usage => <<"EOF";
usage: $0 generate plugin [NAME]
EOF
has description => "Generate Mojolicious plugin directory structure.\n";
has usage => "usage: $0 generate plugin [NAME]\n";

# "There we were in the park when suddenly some old lady says I stole her
# purse.
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojolicious/Command/get.pm
@@ -1,7 +1,7 @@
package Mojolicious::Command::get;
use Mojo::Base 'Mojo::Command';

use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;
use Mojo::DOM;
use Mojo::IOLoop;
use Mojo::JSON;
Expand All @@ -10,10 +10,8 @@ use Mojo::Transaction::HTTP;
use Mojo::UserAgent;
use Mojo::Util qw/decode encode/;

has description => <<'EOF';
Perform HTTP 1.1 request.
EOF
has usage => <<"EOF";
has description => "Perform HTTP 1.1 request.\n";
has usage => <<"EOF";
usage: $0 get [OPTIONS] URL [SELECTOR|JSON-POINTER] [COMMANDS]
mojo get /
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Command/inflate.pm
Expand Up @@ -3,12 +3,8 @@ use Mojo::Base 'Mojo::Command';

use Mojo::Util 'encode';

has description => <<'EOF';
Inflate embedded files to real files.
EOF
has usage => <<"EOF";
usage: $0 inflate
EOF
has description => "Inflate embedded files to real files.\n";
has usage => "usage: $0 inflate\n";

# "Come on stem cells! Work your astounding scientific nonsense!"
sub run {
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Command/psgi.pm
Expand Up @@ -3,12 +3,8 @@ use Mojo::Base 'Mojo::Command';

use Mojo::Server::PSGI;

has description => <<'EOF';
Start application with PSGI.
EOF
has usage => <<"EOF";
usage: $0 psgi
EOF
has description => "Start application with PSGI.\n";
has usage => "usage: $0 psgi\n";

# "In the end it was not guns or bombs that defeated the aliens,
# but that humblest of all God's creatures... the Tyrannosaurus Rex."
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojolicious/Command/routes.pm
Expand Up @@ -2,12 +2,10 @@ package Mojolicious::Command::routes;
use Mojo::Base 'Mojo::Command';

use re 'regexp_pattern';
use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;

has description => <<'EOF';
Show available routes.
EOF
has usage => <<"EOF";
has description => "Show available routes.\n";
has usage => <<"EOF";
usage: $0 routes [OPTIONS]
These options are available:
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojolicious/Command/test.pm
Expand Up @@ -4,12 +4,10 @@ use Mojo::Base 'Mojo::Command';
use Cwd;
use FindBin;
use File::Spec;
use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;

has description => <<'EOF';
Run unit tests.
EOF
has usage => <<"EOF";
has description => "Run unit tests.\n";
has usage => <<"EOF";
usage: $0 test [OPTIONS] [TESTS]
These options are available:
Expand Down
9 changes: 2 additions & 7 deletions lib/Mojolicious/Command/version.pm
Expand Up @@ -6,13 +6,8 @@ use Mojo::Server::Daemon;
use Mojo::UserAgent;
use Mojolicious;

has description => <<'EOF';
Show versions of installed modules.
EOF
has usage => <<"EOF";
usage: $0 version
EOF
has description => "Show versions of installed modules.\n";
has usage => "usage: $0 version\n";

# "It's so cold, my processor is running at peak efficiency!"
sub run {
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Commands.pm
Expand Up @@ -2,7 +2,7 @@ package Mojolicious::Commands;
use Mojo::Base 'Mojo::Command';

use Getopt::Long
qw/GetOptions :config pass_through no_ignore_case no_auto_abbrev/;
qw/GetOptions :config no_auto_abbrev no_ignore_case pass_through/;

# "One day a man has everything, the next day he blows up a $400 billion
# space station, and the next day he has nothing. It makes you think."
Expand Down
2 changes: 1 addition & 1 deletion script/hypnotoad
Expand Up @@ -16,7 +16,7 @@ Please visit http://mojolicio.us for detailed installation instructions.
EOF

use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;

# "Hey sexy mama, wanna kill all humans?"
my $toad = Mojo::Server::Hypnotoad->new;
Expand Down
2 changes: 1 addition & 1 deletion script/morbo
Expand Up @@ -16,7 +16,7 @@ Please visit http://mojolicio.us for detailed installation instructions.
EOF

use Getopt::Long qw/GetOptions :config no_ignore_case no_auto_abbrev/;
use Getopt::Long qw/GetOptions :config no_auto_abbrev no_ignore_case/;

# "Welcome to 'Entertainment And Earth Invasion Tonite'.
# Across the galaxy my people are completing the mighty space fleet that
Expand Down

0 comments on commit 5739bfe

Please sign in to comment.