Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

CLI shell over the library’s typed lifecycle drivers.

The typed core — the LifecycleService trait, driver functions (create, enable, disable, show, delete, status_for), and the *Outcome types — lives in zad::service::lifecycle. This module adds the CLI-only layer:

  1. CliLifecycle — extends LifecycleService with a clap::Args-derived CreateArgs associated type and an interactive resolve step that turns CLI flags into (Cfg, Secrets).
  2. clap arg structs — CreateArgsBase, BotTokenArgs, ScopesArg, EnableArgs, DisableArgs, ShowArgs, StatusArgs, DeleteArgs. Per-service CreateArgs flatten these in.
  3. run_* driver wrappers that prompt where needed, call into the library drivers, and render the typed *Outcome values to stdout in human or JSON form.
  4. resolve_bot_token / resolve_scopes — the only places dialoguer is invoked from inside the lifecycle layer.

Structs§

BotTokenArgs
Drop-in clap flags for a single bot-token credential.
CreateArgsBase
Flags every zad service create <name> accepts.
DeleteArgs
DisableArgs
EnableArgs
ProjectBlock
ScopeBlock
Per-scope view of credentials, for show / status output.
ScopesArg
Drop-in clap flag for the common “comma-separated scopes” pattern.
SecretRef
One OS-keychain entry belonging to a service.
ServiceStatusOutput
Per-service envelope for zad service status --service <svc>.
ShowArgs
StatusArgs
StatusBlock
One scope’s view for status. check is populated only for the effective scope.
StatusCheck

Traits§

CliLifecycle
CLI-side extension of the library’s LifecycleService. Adds the clap-derived CreateArgs shape and the interactive resolve step. Implementors live in cli/service_<name>.rs alongside their LifecycleService impl.
CreateArgsLike
Lets the driver read CreateArgsBase out of a service-specific wrapper.
LifecycleService
Library-shaped lifecycle plumbing for one service. Implement this when adding a new service so the typed create / enable / … driver functions below work for it.

Functions§

leak
Leak an owned String to satisfy Scope::Project(&'a str). Safe in fire-and-forget binaries: the process runs one command and exits, so the “leak” ends with the process. Library callers in long-lived processes should construct Scope::Project(&slug) from a string they own and avoid this helper.
resolve_bot_token
resolve_scopes
run_create
run_delete
run_disable
run_enable
run_show
run_status
Run zad service status --service <svc> for service T. Emits JSON or human output, then exits the process with code 1 if the effective scope failed its live ping.
status_for
Collect the status envelope for service T without emitting anything. Pings only the effective scope.