Skip to content

Python API

The package exports a small public API intended for parser annotation, snapshot extraction, activation rendering, and cache refresh.

CompletionKind

Enum used to describe supported built-in completion kinds.

Current values include:

  • CompletionKind.PLAIN
  • CompletionKind.CHOICE
  • CompletionKind.FILE
  • CompletionKind.RESOLVER

Use it with set_completion() when an argument should be treated as something other than the default plain value.

set_completion(action, *, kind=None, resolver=None)

Attach completion metadata to an argparse action.

Typical uses:

path = parser.add_argument("--path")
set_completion(path, kind=CompletionKind.FILE)

profile = parser.add_argument("--profile")
set_completion(profile, resolver="config_profiles")

extract_snapshot(parser, *, cli_name, distribution_name, package_version, entrypoint=None, fallback_command=None)

Extract a Snapshot model from an existing parser.

Use this when you want direct programmatic control over snapshot generation rather than going through the CLI wrapper.

refresh_from_parser(parser, ...)

Generate cache artifacts directly from an already-constructed parser.

Returns the snapshot, cache paths, and whether a refresh happened.

refresh_from_parser_factory(parser_factory, ...)

Generate cache artifacts from a module:callable style parser factory.

This is the main programmatic path behind the acs-refresh refresh command.

render_activation(...)

Render the Bash activation snippet for a CLI.

This is the same runtime bootstrap emitted by acs-refresh print-activation.

Data models

The top-level package also exports the snapshot-related model types:

  • Snapshot
  • CommandNode
  • OptionMetadata
  • ValueSpec
  • RuntimeMetadata
  • CachePaths

These are useful if you need to inspect or test extracted state directly.