howdy/flags/cli

Command-line management of an app’s flags, for servers without the admin. Give it the app’s flags and a way to open their store, in a task module:

// src/tasks/flags.gleam
import howdy/flags/cli
import howdy/flags/database as flags_database

pub fn main() -> Nil {
  cli.main(my_app.all_flags(), fn() {
    flags_database.store(my_app.database())
  })
}
gleam run -m tasks/flags list
gleam run -m tasks/flags rollout new_checkout 5

In a release built with gleam export erlang-shipment, run it from the release directory, with the arguments after -extra:

erl -pa */ebin -noshell -eval 'tasks@flags:main()' -extra list

Changes go straight to the store and running nodes pick them up at their next check. Each is recorded as made by --by, or cli:$USER. export needs no store: it prints the flags the code defines.

Types

What a command printed, and its exit status: 0 for success, 1 when the command failed, 2 when it was not understood.

pub type Outcome {
  Outcome(status: Int, output: String)
}

Constructors

  • Outcome(status: Int, output: String)

Values

pub fn main(
  defined: List(flags.Flag),
  open: fn() -> Result(flags.Store, service.Error),
) -> Nil

Run the command the process was started with, print what it says, and exit with its status.

pub fn run(
  defined: List(flags.Flag),
  open: fn() -> Result(flags.Store, service.Error),
  arguments: List(String),
) -> Outcome

Run one command without printing or exiting.

✨ Search Document