cyclopts API reference
128 public APIs from cyclopts (BrianPugh/cyclopts) — 46 classes, 42 functions, 40 methods. Signatures extracted by static analysis of the actual source.
Repository: BrianPugh/cyclopts
| Kind | Count |
|---|---|
| Classes | 46 |
| Functions | 42 |
| Methods | 40 |
API list
func
cyclopts._convert.convert_enum_flag(enum_type:type[F], tokens:Iterable[str] | Iterable['Token'], name_transform:Callable[[str], str]) -> FConvert tokens to a Flag enum value.
func
cyclopts._convert.create_empty_instance(hint:Any) -> AnyCreate an empty instance of ``hint``'s container type.
func
cyclopts._convert.get_enum_member(type_:type[E], token:Union['Token', str], name_transform:Callable[[str], str]) -> EMatch a token's value to an enum's member.
func
cyclopts._convert.instantiate_from_dict(type_:type[T], data:dict[str, Any]) -> TInstantiate a type with proper handling of parameter kinds.
class
cyclopts._edit.EditorDidNotChangeErrorUser did not edit file contents in :func:`.edit`.
class
cyclopts._edit.EditorDidNotSaveErrorUser did not save upon exiting :func:`.edit`.
class
cyclopts._edit.EditorErrorRoot editor-related error.
class
cyclopts._edit.EditorNotFoundErrorCould not find a valid text editor for :func`.edit`.
func
cyclopts._env_var.env_var_split(type_:Any, val:str, *delimiter:str | None=None) -> list[str]Type-dependent environment variable value splitting.
func
cyclopts._markup.escape_html(text:str | None) -> strEscape special HTML characters in text.
func
cyclopts._markup.escape_markdown(text:str | None) -> str | NoneEscape special markdown characters in text.
func
cyclopts._markup.escape_rst(text:str | None) -> strEscape special reStructuredText characters in text.
func
cyclopts._markup.extract_text(obj:Any, console:Optional['Console']=None, preserve_markup:bool=False) -> strExtract text from Rich renderables or any object.
func
cyclopts._result_action.handle_result_action(result:Any, action:ResultAction, print_fn:Callable[[Any], None]) -> AnyHandle command result based on result_action.
func
cyclopts._result_action.resolve_returncode(result:Any, default:int=0) -> intResolve the return code for ``result``.
func
cyclopts.annotations.is_enum(hint) -> boolCheck if a type hint is an enum.Enum subclass.
func
cyclopts.annotations.is_enum_flag(hint) -> boolCheck if a type hint is an enum.Flag subclass.
func
cyclopts.annotations.is_typeddict(hint) -> boolDetermine if a type annotation is a TypedDict.
func
cyclopts.annotations.is_union(type_:type | None) -> boolChecks if a type is a union.
func
cyclopts.annotations.is_unpack(type_:Any) -> boolCheck if a type is ``typing.Unpack[...]`` (PEP-646 / PEP-692).
func
cyclopts.annotations.resolve(type_:Any) -> typePerform all simplifying resolutions.
func
cyclopts.annotations.resolve_optional(type_:Any) -> AnyOnly resolves Union's of None + one other type (i.e.
func
cyclopts.annotations.resolve_type_alias(type_:Any) -> AnyResolve TypeAliasType (Python 3.12+ 'type' statement) to its underlying type.
func
cyclopts.annotations.resolve_unpack(type_:Any) -> AnyUnwrap ``Unpack[X]`` to ``X``.
method
cyclopts.argument._argument.Argument.append(token:Token)Safely add a :class:`Token`.
method
cyclopts.argument._argument.Argument.get_choices(force:bool=False) -> tuple[str, ...] | NoneExtract completion choices from type hint.
method
cyclopts.argument._argument.Argument.name() -> strThe **first** provided name this argument goes by.
method
cyclopts.argument._argument.Argument.parse() -> boolWhether this argument should be parsed from CLI tokens.
method
cyclopts.argument._argument.Argument.show() -> boolShow this argument on the help page.
method
cyclopts.argument._argument.Argument.show_default() -> bool | str | Callable[[Any], str]Show the default value on the help page.
method
cyclopts.argument._argument.Argument.token_count(keys:tuple[str, ...]=())The number of string tokens this argument consumes.
method
cyclopts.argument._argument.Argument.validate(value)Validates provided value.
class
cyclopts.argument._collection.ArgumentCollectionA list-like container for :class:`Argument`.
func
cyclopts.argument.utils.get_choices_from_hint(type_:type, name_transform:Callable[[str], str]) -> list[str]Extract completion choices from a type hint.
method
cyclopts.command_spec.CommandSpec.resolve(parent_app:'App') -> 'App'Import and resolve the command on first access.
class
cyclopts.completion._base.CompletionActionShell-agnostic completion action types.
class
cyclopts.completion._base.CompletionDataCompletion data for a command path.
func
cyclopts.completion._base.clean_choice_text(text:str) -> strClean choice text without shell-specific escaping.
func
cyclopts.completion._base.escape_for_shell_pattern(name:str, chars:str='*?[]') -> strEscape glob/pattern characters for shell case patterns.
func
cyclopts.completion._base.get_completion_action(type_hint:Any) -> CompletionActionGet completion action from type hint.
func
cyclopts.completion._base.strip_markup(text:str, format:str='markdown', max_length:int=80) -> strStrip markup and render to plain text for shell completions.
func
cyclopts.completion.bash.generate_completion_script(app:'App', prog_name:str) -> strGenerate bash completion script.
class
cyclopts.completion.detect.ShellDetectionErrorRaised when the shell type cannot be detected.
func
cyclopts.completion.fish.generate_completion_script(app:'App', prog_name:str) -> strGenerate fish completion script.
func
cyclopts.completion.install.add_to_rc_file(script_path:Path, prog_name:str, shell:Literal['bash', 'zsh']) -> boolAdd completion configuration to shell RC file.
func
cyclopts.completion.zsh.generate_completion_script(app:'App', prog_name:str) -> strGenerate zsh completion script.
class
cyclopts.config._common.ConfigBaseBase class for configuration sources.
method
cyclopts.config._common.ConfigBase.config() -> dict[str, Any]Return the configuration dictionary.
class
cyclopts.config._common.ConfigFromFileConfiguration source that loads from a file.
class
cyclopts.config._common.DictConfiguration source from an in-memory dictionary.
method
cyclopts.core.App.assemble_argument_collection(*default_parameter:Parameter | None=None, *parse_docstring:bool=False) -> ArgumentCollectionAssemble the argument collection for this app.
method
cyclopts.core.App.help_print(tokens:Annotated[None | str | Iterable[str], Parameter(show=False)]=None, *console:Annotated[Optional['Console'], Parameter(parse=False)]=None) -> NonePrint the help page.
method
cyclopts.core.App.name() -> tuple[str, ...]Application name(s).
method
cyclopts.core.App.resolved_commands() -> dict[str, 'App']Get all commands as resolved App instances.
method
cyclopts.core.App.update(app:'App')Copy over all commands from another :class:`App`.
method
cyclopts.core.App.version_print(console:Annotated[Optional['Console'], Parameter(parse=False)]=None) -> NonePrint the application version.
class
cyclopts.exceptions.CoercionErrorThere was an error performing automatic type coercion.
class
cyclopts.exceptions.CycloptsErrorRoot exception for runtime errors.
class
cyclopts.exceptions.MissingArgumentErrorA required argument was not provided.
class
cyclopts.exceptions.MixedArgumentErrorCannot supply keywords and non-keywords to the same argument.
class
cyclopts.exceptions.RepeatArgumentErrorThe same parameter has erroneously been specified multiple times.
class
cyclopts.exceptions.UnknownCommandErrorCLI token combination did not yield a valid command.
class
cyclopts.exceptions.UnknownOptionErrorUnknown/unregistered option provided by the cli.
class
cyclopts.exceptions.UnusedCliTokensErrorNot all CLI tokens were used as expected.
class
cyclopts.exceptions.ValidationErrorValidator function raised an exception.
class
cyclopts.ext.mkdocs.CycloptsPluginMkDocs plugin to generate Cyclopts CLI documentation.
class
cyclopts.ext.mkdocs.CycloptsPluginConfigConfiguration schema for the Cyclopts MkDocs plugin.
class
cyclopts.ext.mkdocs.DirectiveOptionsConfiguration for the ::: cyclopts directive.
func
cyclopts.ext.mkdocs.is_in_code_block(pos:int) -> boolCheck if a position is inside a code block.
func
cyclopts.ext.mkdocs.process_cyclopts_directives(markdown:str, plugin_config:Any) -> strProcess all ::: cyclopts directives in markdown content.
class
cyclopts.ext.sphinx.CycloptsDirectiveSphinx directive for documenting Cyclopts CLI applications.
method
cyclopts.ext.sphinx.CycloptsDirective.run() -> list['nodes.Node']Generate documentation nodes for the Cyclopts app.
class
cyclopts.ext.sphinx.DirectiveOptionsConfiguration for the Cyclopts directive.
method
cyclopts.ext.sphinx.DirectiveOptions.from_dict(options:dict) -> 'DirectiveOptions'Create options from directive options dictionary.
class
cyclopts.field_info.FieldInfoExtension of :class:`inspect.Parameter`.
method
cyclopts.field_info.FieldInfo.name()The **first** provided name.
func
cyclopts.group.sort_groups(groups:list[Group], attributes:list[Any]) -> tuple[list[Group], list[Any]]Sort groups for the help-page.
class
cyclopts.group_extractors.RegisteredCommandA command with the names it was registered under.
class
cyclopts.help.formatters.html.HtmlFormatterHTML documentation formatter.
method
cyclopts.help.formatters.html.HtmlFormatter.get_output() -> strGet the accumulated HTML output.
method
cyclopts.help.formatters.html.HtmlFormatter.render_description(console:Optional['Console'], options:Optional['ConsoleOptions'], description:Any) -> NoneRender the description as HTML.
method
cyclopts.help.formatters.html.HtmlFormatter.render_usage(console:Optional['Console'], options:Optional['ConsoleOptions'], usage:Any) -> NoneRender the usage line as HTML.
method
cyclopts.help.formatters.html.HtmlFormatter.reset() -> NoneReset the internal output buffer.
class
cyclopts.help.formatters.markdown.MarkdownFormatterMarkdown documentation formatter.
method
cyclopts.help.formatters.markdown.MarkdownFormatter.get_output() -> strGet the accumulated markdown output.
method
cyclopts.help.formatters.markdown.MarkdownFormatter.render_description(console:Optional['Console'], options:Optional['ConsoleOptions'], description:Any) -> NoneRender the description as markdown.
method
cyclopts.help.formatters.markdown.MarkdownFormatter.render_usage(console:Optional['Console'], options:Optional['ConsoleOptions'], usage:Any) -> NoneRender the usage line as markdown.
method
cyclopts.help.formatters.markdown.MarkdownFormatter.reset() -> NoneReset the internal output buffer.
class
cyclopts.help.formatters.plain.PlainFormatterPlain text formatter for improved accessibility.
method
cyclopts.help.formatters.plain.PlainFormatter.render_description(console:'Console', options:'ConsoleOptions', description:Any) -> NoneRender the description.
method
cyclopts.help.formatters.plain.PlainFormatter.render_usage(console:'Console', options:'ConsoleOptions', usage:Any) -> NoneRender the usage line.
class
cyclopts.help.formatters.rst.RstFormatterreStructuredText documentation formatter.
method
cyclopts.help.formatters.rst.RstFormatter.get_output() -> strGet the accumulated RST output.
method
cyclopts.help.formatters.rst.RstFormatter.render_description(console:Optional['Console'], options:Optional['ConsoleOptions'], description:Any) -> NoneRender the description as RST.
method
cyclopts.help.formatters.rst.RstFormatter.render_usage(console:Optional['Console'], options:Optional['ConsoleOptions'], usage:Any) -> NoneRender the usage line as RST.
method
cyclopts.help.formatters.rst.RstFormatter.reset() -> NoneReset the internal output buffer.
class
cyclopts.help.help.HelpEntryContainer for help table entry data.
method
cyclopts.help.help.HelpEntry.names() -> tuple[str, ...]All long option names (positive + negative).
method
cyclopts.help.help.HelpEntry.shorts() -> tuple[str, ...]All short option names (positive + negative).
class
cyclopts.help.help.HelpPanelData container for help panel information.
func
cyclopts.help.help.format_command_entries(apps_with_names:Iterable, format:str) -> list[HelpEntry]Format command entries for help display.
class
cyclopts.help.protocols.ColumnSpecBuilderProtocol for ColumnSpecBuilders.
class
cyclopts.help.protocols.HelpFormatterProtocol for help **formatter** functions.
class
cyclopts.help.silent.SilentRichDummy object that causes nothing to be printed.
class
cyclopts.help.specs.AsteriskRendererRenderer for required parameter asterisk indicator.
class
cyclopts.help.specs.ColumnSpecSpecification for a single column in a help table.
class
cyclopts.help.specs.CommandNameRendererRenderer for command names with aliases in parentheses.
class
cyclopts.help.specs.PanelSpecSpecification for panel (outer box) styling.
method
cyclopts.help.specs.PanelSpec.build(renderable:'RenderableType', **overrides) -> 'Panel'Create a Panel around `renderable`.
class
cyclopts.help.specs.TableSpecSpecification for table layout and styling.
method
cyclopts.help.specs.TableSpec.build(columns:tuple[ColumnSpec, ...], entries:Iterable['HelpEntry'], **overrides) -> 'Table'Construct and populate a rich.Table.
func
cyclopts.loader.load_app_from_script(script:str | Path) -> tuple['App', str]Load a Cyclopts App object from a Python script.
func
cyclopts.panel.CycloptsPanel(message:Any, title:str='Error', style:str='red') -> 'Panel'Create a :class:`~rich.panel.Panel` with a consistent style.
method
cyclopts.parameter.Parameter.default() -> SelfCreate a Parameter with all Cyclopts-default values.
method
cyclopts.parameter.Parameter.from_annotation(type_:Any, *default_parameters:'Parameter | None') -> tuple[Any, 'Parameter']Resolve the immediate Parameter from a type hint.
func
cyclopts.parameter.get_parameters(hint:T, skip_converter_params:bool=False) -> tuple[T, list[Parameter]]At root level, checks for cyclopts.Parameter annotations.
func
cyclopts.parameter.validate_command(f:Callable)Validate if a function abides by Cyclopts's rules.
class
cyclopts.token.TokenTracks how a user supplied a value to the application.
method
cyclopts.token.Token.address() -> tuple[tuple[str, ...], int]Hashable subkey destination address for this token.
class
cyclopts.utils.UNSETSpecial sentinel value indicating that no data was provided.
func
cyclopts.utils.default_name_transform(s:str) -> strConverts a python identifier into a CLI token.
func
cyclopts.utils.import_app(module_path:str)Import a Cyclopts App from a module path.
func
cyclopts.utils.is_option_like(token:str, *allow_numbers=False) -> boolChecks if a token looks like an option.
func
cyclopts.utils.slice_to_str(value:slice) -> strFormat a slice in slice notation (e.g.
func
cyclopts.utils.sort_key_converter(value:Any) -> AnyConvert sort_key value, consuming generators with :func:`next`.
class
cyclopts.validators._number.NumberLimit input number to a value range.
class
cyclopts.validators._path.PathAssertions on properties of :class:`pathlib.Path`.
class
cyclopts.validators._slice.SliceAssertions on properties of a :class:`slice`.
About this data
These signatures were extracted from the public source of BrianPugh/cyclopts
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.