Pyjoyment.Command.eval - Eval command¶
Usage: APPLICATION eval [OPTIONS] CODE
./myapp.py eval 'print(app.ua.get("/").result.body)'
./myapp.py eval 'print(*sorted(app.renderer.helpers), sep="\n")'
./myapp.py eval -v 'app.home'
./myapp.py eval -V 'app.renderer.paths'
Options:
-h, --help Show this summary of available options
--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", "plain" without
time and process, 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"
-v, --verbose Print return value to sys.stdout
-V Print returned data structure to sys.stdout
Pyjoyment.Command.eval runs code against applications. The code
is Python, with the application as app, and its result is the value of its
last expression. If the result is a promise (then-able), it will wait until
the promise is fulfilled or rejected and the result is returned.
This is a core command, that means it is always enabled and its code a good example for learning to build new commands, you’re welcome to fork it.
See Pyjoyment.Commands for a list of commands that are available by
default.
See also¶
Pyjoyment, https://mojolicious.org.
Ported from Mojolicious::Command::eval of Mojolicious 9.49.
Classes¶
- class Pyjoyment.Command.eval.Pyjoyment_Command_eval(**kwargs: Any)[source]¶
Pyjoyment.Command.evalinherits all attributes and methods fromPyjoyment.Commandand implements the following new ones.- description = 'Run code against application'¶
description = eval.description eval.description = 'Foo'
Short description of this command, used for the command list.
- usage = 'Usage: APPLICATION eval [OPTIONS] CODE\n\n ./myapp.py eval \'print(app.ua.get("/").result.body)\'\n ./myapp.py eval \'print(*sorted(app.renderer.helpers), sep="\\n")\'\n ./myapp.py eval -v \'app.home\'\n ./myapp.py eval -V \'app.renderer.paths\'\n\nOptions:\n -h, --help Show this summary of available options\n --home <path> Path to home directory of your application,\n defaults to the value of PYJO_HOME or\n auto-detection\n --log-format <name> Format of log messages, "text", "plain" without\n time and process, or "json", defaults to the\n value of PYJO_LOG_FORMAT or "text"\n -m, --mode <name> Operating mode for your application, defaults to\n the value of PYJO_MODE or "development"\n -v, --verbose Print return value to sys.stdout\n -V Print returned data structure to sys.stdout\n'¶
usage = eval.usage eval.usage = 'Foo'
Usage information for this command, used for the help screen.