Pyjoyment.Commands - Command line interface¶
Usage: APPLICATION COMMAND [OPTIONS]
pyjo version
pyjo generate lite-app
./myapp.py daemon -m production -l http://*:8080
./myapp.py get /foo
./myapp.py routes -v
Tip: CGI, FastCGI and AWS Lambda environments, and WSGI and ASGI ones with
PYJO_WSGI and PYJO_ASGI, can be automatically detected very often and
work without commands.
Options (for all commands):
-h, --help Get more information on a specific command
--home <path> Path to home directory of your application,
defaults to the value of PYJO_HOME or
auto-detection
--log-format <name> Format of log messages, "text" or "json",
defaults to the value of PYJO_LOG_FORMAT or
"text"
-m, --mode <name> Operating mode for your application, defaults to
the value of PYJO_MODE or "development"
Pyjoyment.Commands is the interactive command line interface for the
Pyjoyment framework. It will automatically detect available commands in
the Pyjoyment.Command and Pyjoyment.Command.Author namespaces.
The command line interface of Pyjoyment.HelloWorld is the pyjo
script, or python -m Pyjoyment.
Commands¶
These commands are available by default.
asgi¶
application = app.start('asgi')
Use Pyjoyment.Command.asgi to start application with ASGI backend,
auto detected with the PYJO_ASGI environment variable.
cgi¶
$ ./myapp.py cgi
Use Pyjoyment.Command.cgi to start application with CGI backend,
usually auto detected.
daemon¶
$ ./myapp.py daemon
Use Pyjoyment.Command.daemon to start application with standalone
HTTP and WebSocket server.
eval¶
$ ./myapp.py eval 'print(app.home)'
Use Pyjoyment.Command.eval to run code against application.
fastcgi¶
$ ./myapp.py fastcgi
Use Pyjoyment.Command.fastcgi to start application with the FastCGI
of a web server that starts it, usually auto detected.
generate¶
$ pyjo generate
$ pyjo generate help
$ ./myapp.py generate help
List available generator commands with short descriptions.
$ pyjo generate help <generator>
$ ./myapp.py generate help <generator>
List available options for generator command with short descriptions.
generate app¶
$ pyjo generate app <AppName>
Use Pyjoyment.Command.Author.generate.app to generate application
directory structure for a fully functional Pyjoyment application.
generate dockerfile¶
$ ./myapp.py generate dockerfile
$ python -m MyApp generate dockerfile
Use Pyjoyment.Command.Author.generate.dockerfile to generate
Dockerfile for application.
generate lite-app¶
$ pyjo generate lite-app
Use Pyjoyment.Command.Author.generate.lite_app to generate a fully
functional Pyjoyment.Lite application.
generate plugin¶
$ pyjo generate plugin <PluginName>
Use Pyjoyment.Command.Author.generate.plugin to generate directory
structure for a fully functional Pyjoyment plugin.
generate pyproject¶
$ pyjo generate pyproject
$ ./myapp.py generate pyproject
Use Pyjoyment.Command.Author.generate.pyproject to generate
pyproject.toml file for application.
get¶
$ pyjo get https://mojolicious.org
$ ./myapp.py get /foo
Use Pyjoyment.Command.get to perform requests to remote host or local
application.
help¶
$ pyjo
$ pyjo help
$ ./myapp.py help
List available commands with short descriptions.
$ pyjo help <command>
$ ./myapp.py help <command>
List available options for the command with short descriptions.
inflate¶
$ ./myapp.py inflate
Use Pyjoyment.Command.Author.inflate to turn templates and static files
embedded in the DATA sections of your application into real files.
lambda¶
handler = app.start('lambda')
Use Pyjoyment.Command.lambda to start application as an event function
of AWS Lambda, auto detected with the AWS_LAMBDA_RUNTIME_API environment
variable.
prefork¶
$ ./myapp.py prefork
Use Pyjoyment.Command.prefork to start application with standalone
pre-forking HTTP and WebSocket server.
prethread¶
$ ./myapp.py prethread
Use Pyjoyment.Command.prethread to start application with standalone
pre-threading HTTP and WebSocket server.
routes¶
$ ./myapp.py routes
Use Pyjoyment.Command.routes to list application routes.
version¶
$ pyjo version
$ ./myapp.py version
Use Pyjoyment.Command.version to show version information for
available core and optional modules, very useful for debugging.
wsgi¶
application = app.start('wsgi')
Use Pyjoyment.Command.wsgi to start application with WSGI backend,
auto detected with the PYJO_WSGI environment variable.
See also¶
Pyjoyment, https://mojolicious.org.
Ported from Mojolicious::Commands of Mojolicious 9.49.
Classes¶
- class Pyjoyment.Commands.Pyjoyment_Commands(**kwargs: Any)[source]¶
Pyjoyment.Commandsinherits all attributes and methods fromPyjoyment.Commandand implements the following new ones.- static detect() str | None[source]¶
env = commands.detect()
Try to detect environment, or return
Noneif none could be detected.
- hint: str = "\nSee 'APPLICATION help COMMAND' for more information on a specific command.\n"¶
hint = commands.hint commands.hint = 'Foo'
Short hint shown after listing available commands.
- property message: str[source]¶
msg = commands.message commands.message = 'Hello World!'
Short usage message shown before listing available commands.
- namespaces: list[str]¶
namespaces = commands.namespaces commands.namespaces = ['MyApp.Command']
Namespaces to load commands from, defaults to
Pyjoyment.Command.AuthorandPyjoyment.Command.# Add another namespace to load commands from commands.namespaces.append('MyApp.Command')
- run(name: str | None = None, *args: str) Any[source]¶
commands.run() commands.run(*sys.argv[1:])
Load and run commands. Automatic deployment environment detection can be disabled with the
PYJO_NO_DETECTenvironment variable. A detected environment, CGI, FastCGI, AWS Lambda, or WSGI and ASGI with thePYJO_WSGIandPYJO_ASGIenvironment variables, runs its command, whatever the arguments are, as a WSGI or an ASGI server and AWS Lambda import the script of the application with their own arguments.# The WSGI application of a script, for PYJO_WSGI=1 gunicorn myapp:application application = app.start()
- static start_app(app: str | type, *args: str) Any[source]¶
Pyjoyment.Commands.start_app('MyApp') Pyjoyment.Commands.start_app('MyApp', *sys.argv[1:])
Load application from class and start the command line interface for it. Note that the options
-h/--help,--homeand-m/--mode, which are shared by all commands, will be parsed fromsys.argvwhen the module is imported.# Always start daemon for application Pyjoyment.Commands.start_app('MyApp', 'daemon', '-l', 'http://*:8080')
- Pyjoyment.Commands.main(argv: Sequence[str] | None = None) None[source]¶
main(['version'])
The command line interface of the
pyjoscript: start the command line interface ofPyjoyment.HelloWorld.
- Pyjoyment.Commands.start_app(app: str | type, *args: str) Any[source]¶
Pyjoyment.Commands.start_app('MyApp') Pyjoyment.Commands.start_app('MyApp', *sys.argv[1:])
Load application from class and start the command line interface for it. Note that the options
-h/--help,--homeand-m/--mode, which are shared by all commands, will be parsed fromsys.argvwhen the module is imported.# Always start daemon for application Pyjoyment.Commands.start_app('MyApp', 'daemon', '-l', 'http://*:8080')