runtime.init¶
Contains all of the middlewares used during initialization of a command
AddRuntimeParmsMiddleware
¶
Bases: MiddlewareBase
Adds runtime-params to the root Command object
Context Dependencies¶
arc.root
Context Additions¶
None
Added Parameters¶
--version / -v
: If there is a version set in the configuration--autocomplete
: If shell completions are enabled
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
AddUsageErrorInfoMiddleware
¶
Bases: MiddlewareBase
A utility middleware that catches UsageError
s and adds information so they can generate a usage error
Context Dependencies¶
arc.command
(optional): Usage information comes from the current executingCommand
object
Context Additions¶
None
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
ArgParseMiddleware
¶
Bases: MiddlewareBase
Middleware that parses the input using the argparse
library
Context Dependencies¶
arc.command
: The command to parse the input forarc.input
: The input to parse
Context Additions¶
arc.parse.result
: The result of the parsingarc.parse.extra
: Any extra arguments that were not parsed
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
CheckParseResultsMiddleware
¶
Bases: MiddlewareBase
Checks the results of the input parsing against configutation options. Generates error messages for unrecognized arguments
Context Dependencies¶
arc.config
arc.parse.extra
(optional)
Context Additions¶
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
CommandFinderMiddleware
¶
Bases: MiddlewareBase
Middleware that finds the command to execute based on the input. Finds the command by walking the tree of commands from the root and comparing them with each next word in the input
Context Dependencies¶
arc.input
: The input to find the command from
Context Additions¶
arc.command
: The command to executearc.input
: The input to pass to the command. Will be what's left of the input after removing the command path
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
InitMiddleware
¶
Bases: DefaultMiddlewareNamespace
Namespace for all the default init middlewares
Use it to reference a default init middleware when adding your own custom middlewares
import arc
@arc.command
def command():
arc.print("hello there")
# To add your own init middlewares, you need to
# create the App object explicitly
app = arc.App(command)
@app.use(before=arc.InitMiddleware.Parser)
def before_parse(ctx: arc.Context):
# Will run before the middleware that performs the parsing operation
...
app()
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
LoadPluginsMiddleware
¶
Bases: MiddlewareBase
Utility Middleware that loads plugins defined in the configuration into the application and calls their hooks
Context Dependencies¶
arc.config
- Configuration objectarc.app
- Application object
Context Additions¶
None
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
NormalizeInputMiddleware
¶
Bases: MiddlewareBase
Middleware that normalizes different input sources. If input is provided when
command is called, it will be normalized to an list. If input is not provided,
sys.argv
is used.
Context Dependencies¶
arc.input
(optional): Only exists if input was provided in the call to the command
Context Additions¶
arc.input
: Adds it if it's not already there, normalizes it if it is there
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
PerformDevChecksMiddleware
¶
Bases: MiddlewareBase
A utility middleware that performs some development checks. Will be disabled in production mode.
Context Dependencies¶
arc.root
- Root Command object to start checks fromarc.concig
- Checks Configuration for enviroment
Context Additions¶
None
Source code in /home/runner/work/arc/arc/arc/runtime/init.py
StartTimeMiddleware
¶
Bases: MiddlewareBase
Utility Middleware that tracks how long execution takes
Context Dependencies¶
None
Context Additions¶
arc.debug.start
- datetime representing the start of executionarc.debug.end
- datetime representing the end of execution.