Skip to content

Dynamic Fallback

Dynamic completion is supported, but only through an explicit contract.

Why fallback exists

Some values cannot be represented as a static snapshot:

  • environment-dependent values
  • network-backed resource names
  • values that change too frequently to cache safely

Those cases should remain dynamic instead of forcing the Bash runtime to guess.

Declare a resolver

region = parser.add_argument("--region")
set_completion(region, resolver="config_regions")

The resolver name is metadata in the snapshot. It is not automatic runtime magic by itself.

Provide a fallback command

acs-refresh print-activation \
  --factory mypackage.cli:build_parser \
  --cli-name mycli \
  --distribution mycli \
  --fallback-command "mycli --resolver-fallback"

Use fallback only when a value source is genuinely dynamic.

What not to do

Do not route static choices or normal file completion through fallback. That just gives up the main performance advantage.

Design guidance

  • snapshot static structure aggressively
  • reserve fallback for live data
  • keep fallback behavior deterministic and easy to test