|
|
|
@ -4,10 +4,42 @@ from superpython.shell import EXIT |
|
|
|
|
from superpython.utils import highlight_code |
|
|
|
|
from ..parsers import load_commands, load_config |
|
|
|
|
|
|
|
|
|
# Exports |
|
|
|
|
|
|
|
|
|
__all__ = ( |
|
|
|
|
"output_commands", |
|
|
|
|
"output_docs", |
|
|
|
|
"output_script", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Functions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def output_commands(path, color_enabled=False, context=None, filters=None, locations=None, options=None): |
|
|
|
|
"""Output commands found in a given configuration file. |
|
|
|
|
|
|
|
|
|
:param path: The path to the configuration file. |
|
|
|
|
:type path: str |
|
|
|
|
|
|
|
|
|
:param color_enabled: Indicates the output should be colorized. |
|
|
|
|
:type color_enabled: bool |
|
|
|
|
|
|
|
|
|
:param context: The context to be applied to the file before parsing it as configuration. |
|
|
|
|
:type context: dict |
|
|
|
|
|
|
|
|
|
:param filters: Output only those commands which match the given filters. |
|
|
|
|
:type filters: dict |
|
|
|
|
|
|
|
|
|
:param locations: The locations (paths) of additional resources. |
|
|
|
|
:type locations: list[str] |
|
|
|
|
|
|
|
|
|
:param options: Options to be applied to all commands. |
|
|
|
|
:type options: dict |
|
|
|
|
|
|
|
|
|
:rtype: int |
|
|
|
|
:returns: An exit code. |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
commands = load_commands( |
|
|
|
|
path, |
|
|
|
|
context=context, |
|
|
|
@ -36,6 +68,27 @@ def output_commands(path, color_enabled=False, context=None, filters=None, locat |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def output_docs(path, context=None, filters=None, locations=None, options=None): |
|
|
|
|
"""Output documentation for commands found in a given configuration file. |
|
|
|
|
|
|
|
|
|
:param path: The path to the configuration file. |
|
|
|
|
:type path: str |
|
|
|
|
|
|
|
|
|
:param context: The context to be applied to the file before parsing it as configuration. |
|
|
|
|
:type context: dict |
|
|
|
|
|
|
|
|
|
:param filters: Output only those commands which match the given filters. |
|
|
|
|
:type filters: dict |
|
|
|
|
|
|
|
|
|
:param locations: The locations (paths) of additional resources. |
|
|
|
|
:type locations: list[str] |
|
|
|
|
|
|
|
|
|
:param options: Options to be applied to all commands. |
|
|
|
|
:type options: dict |
|
|
|
|
|
|
|
|
|
:rtype: int |
|
|
|
|
:returns: An exit code. |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
commands = load_commands( |
|
|
|
|
path, |
|
|
|
|
context=context, |
|
|
|
@ -58,6 +111,30 @@ def output_docs(path, context=None, filters=None, locations=None, options=None): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def output_script(path, color_enabled=False, context=None, filters=None, locations=None, options=None): |
|
|
|
|
"""Output a script of commands found in a given configuration file. |
|
|
|
|
|
|
|
|
|
:param path: The path to the configuration file. |
|
|
|
|
:type path: str |
|
|
|
|
|
|
|
|
|
:param color_enabled: Indicates the output should be colorized. |
|
|
|
|
:type color_enabled: bool |
|
|
|
|
|
|
|
|
|
:param context: The context to be applied to the file before parsing it as configuration. |
|
|
|
|
:type context: dict |
|
|
|
|
|
|
|
|
|
:param filters: Output only those commands which match the given filters. NOT IMPLEMENTED. |
|
|
|
|
:type filters: dict |
|
|
|
|
|
|
|
|
|
:param locations: The locations (paths) of additional resources. |
|
|
|
|
:type locations: list[str] |
|
|
|
|
|
|
|
|
|
:param options: Options to be applied to all commands. |
|
|
|
|
:type options: dict |
|
|
|
|
|
|
|
|
|
:rtype: int |
|
|
|
|
:returns: An exit code. |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
config = load_config( |
|
|
|
|
path, |
|
|
|
|
context=context, |
|
|
|
|