1Mojolicious::Commands(3U)ser Contributed Perl DocumentatiMoonjolicious::Commands(3)
2
3
4
6 Mojolicious::Commands - Command line interface
7
9 Usage: APPLICATION COMMAND [OPTIONS]
10
11 mojo version
12 mojo generate lite-app
13 ./myapp.pl daemon -m production -l http://*:8080
14 ./myapp.pl get /foo
15 ./myapp.pl routes -v
16
17 Tip: CGI and PSGI environments can be automatically detected very often and
18 work without commands.
19
20 Options (for all commands):
21 -h, --help Get more information on a specific command
22 --home <path> Path to home directory of your application, defaults to
23 the value of MOJO_HOME or auto-detection
24 -m, --mode <name> Operating mode for your application, defaults to the
25 value of MOJO_MODE/PLACK_ENV or "development"
26
28 Mojolicious::Commands is the interactive command line interface for the
29 Mojolicious framework. It will automatically detect available commands
30 in the "Mojolicious::Command" and "Mojolicious::Command::Author"
31 namespaces.
32
34 These commands are available by default.
35
36 cgi
37 $ ./myapp.pl cgi
38
39 Use Mojolicious::Command::cgi to start application with CGI backend,
40 usually auto detected.
41
42 cpanify
43 $ mojo cpanify -u sri -p secr3t Mojolicious-Plugin-Fun-0.1.tar.gz
44
45 Use Mojolicious::Command::Author::cpanify for uploading files to CPAN.
46
47 daemon
48 $ ./myapp.pl daemon
49
50 Use Mojolicious::Command::daemon to start application with standalone
51 HTTP and WebSocket server.
52
53 eval
54 $ ./myapp.pl eval 'say app->home'
55
56 Use Mojolicious::Command::eval to run code against application.
57
58 generate
59 $ mojo generate
60 $ mojo generate help
61 $ ./myapp.pl generate help
62
63 List available generator commands with short descriptions.
64
65 $ mojo generate help <generator>
66 $ ./myapp.pl generate help <generator>
67
68 List available options for generator command with short descriptions.
69
70 generate app
71 $ mojo generate app <AppName>
72
73 Use Mojolicious::Command::Author::generate::app to generate application
74 directory structure for a fully functional Mojolicious application.
75
76 generate dockerfile
77 $ ./myapp.pl generate dockerfile
78 $ ./script/my_app generate dockerfile
79
80 Use Mojolicious::Command::Author::generate::dockerfile to generate
81 "Dockerfile" for application.
82
83 generate lite-app
84 $ mojo generate lite-app
85
86 Use Mojolicious::Command::Author::generate::lite_app to generate a
87 fully functional Mojolicious::Lite application.
88
89 generate makefile
90 $ mojo generate makefile
91 $ ./myapp.pl generate makefile
92
93 Use Mojolicious::Command::Author::generate::makefile to generate
94 "Makefile.PL" file for application.
95
96 generate plugin
97 $ mojo generate plugin <PluginName>
98
99 Use Mojolicious::Command::Author::generate::plugin to generate
100 directory structure for a fully functional Mojolicious plugin.
101
102 get
103 $ mojo get https://mojolicious.org
104 $ ./myapp.pl get /foo
105
106 Use Mojolicious::Command::get to perform requests to remote host or
107 local application.
108
109 help
110 $ mojo
111 $ mojo help
112 $ ./myapp.pl help
113
114 List available commands with short descriptions.
115
116 $ mojo help <command>
117 $ ./myapp.pl help <command>
118
119 List available options for the command with short descriptions.
120
121 inflate
122 $ ./myapp.pl inflate
123
124 Use Mojolicious::Command::Author::inflate to turn templates and static
125 files embedded in the "DATA" sections of your application into real
126 files.
127
128 prefork
129 $ ./myapp.pl prefork
130
131 Use Mojolicious::Command::prefork to start application with standalone
132 pre-forking HTTP and WebSocket server.
133
134 psgi
135 $ ./myapp.pl psgi
136
137 Use Mojolicious::Command::psgi to start application with PSGI backend,
138 usually auto detected.
139
140 routes
141 $ ./myapp.pl routes
142
143 Use Mojolicious::Command::routes to list application routes.
144
145 version
146 $ mojo version
147 $ ./myapp.pl version
148
149 Use Mojolicious::Command::version to show version information for
150 available core and optional modules, very useful for debugging.
151
153 Mojolicious::Commands inherits all attributes from Mojolicious::Command
154 and implements the following new ones.
155
156 hint
157 my $hint = $commands->hint;
158 $commands = $commands->hint('Foo');
159
160 Short hint shown after listing available commands.
161
162 message
163 my $msg = $commands->message;
164 $commands = $commands->message('Hello World!');
165
166 Short usage message shown before listing available commands.
167
168 namespaces
169 my $namespaces = $commands->namespaces;
170 $commands = $commands->namespaces(['MyApp::Command']);
171
172 Namespaces to load commands from, defaults to
173 "Mojolicious::Command::Author" and "Mojolicious::Command".
174
175 # Add another namespace to load commands from
176 push @{$commands->namespaces}, 'MyApp::Command';
177
179 Mojolicious::Commands inherits all methods from Mojolicious::Command
180 and implements the following new ones.
181
182 detect
183 my $env = $commands->detect;
184
185 Try to detect environment, or return "undef" if none could be detected.
186
187 run
188 $commands->run;
189 $commands->run(@ARGV);
190
191 Load and run commands. Automatic deployment environment detection can
192 be disabled with the "MOJO_NO_DETECT" environment variable.
193
194 start_app
195 Mojolicious::Commands->start_app('MyApp');
196 Mojolicious::Commands->start_app(MyApp => @ARGV);
197
198 Load application from class and start the command line interface for
199 it. Note that the options "-h"/"--help", "--home" and "-m"/"--mode",
200 which are shared by all commands, will be parsed from @ARGV during
201 compile time.
202
203 # Always start daemon for application
204 Mojolicious::Commands->start_app('MyApp', 'daemon', '-l', 'http://*:8080');
205
207 Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
208
209
210
211perl v5.36.0 2022-07-22 Mojolicious::Commands(3)