rad/workbook

Types

A collection of tasks, each of which can be run from the rad command line interface.

A Workbook can be conveniently built up using the following functions: new, followed by any number of task, tasks, and delete.

Any number of tasks can be added to a new or existing Workbook, such as the standard workbook, to compose a custom Workbook that can be given to rad.do_main.

pub type Workbook =
  Dict(List(String), Task(Result))

Functions

pub fn delete(
  from workbook: Dict(List(String), Task(Result(String, Snag))),
  task path: List(String),
) -> Dict(List(String), Task(Result(String, Snag)))

Returns a new Workbook with any Task at the given path removed.

pub fn from_tasks(
  list: List(Task(Result(String, Snag))),
) -> Dict(List(String), Task(Result(String, Snag)))

Converts a list of Tasks into a Workbook.

pub fn get(
  from workbook: Dict(List(String), Task(Result(String, Snag))),
  task path: List(String),
) -> Result(Task(Result(String, Snag)), Nil)

Results in the Task with the given path on success, or Nil on failure.

pub fn heading(name: String) -> String

Returns a stylized heading with the given name.

pub fn help(
  from workbook_fun: fn() ->
    Dict(List(String), Task(Result(String, Snag))),
) -> fn(CommandInput, Task(Result(String, Snag))) ->
  Result(String, Snag)

Builds help dialogues for the given Workbook and any of its tasks.

Any Task with an empty shortdoc field, or for which no parent Task exists, is hidden from ancestor help dialogues, but can be viewed directly.

Similarly, any flag with an empty description will be hidden from all help dialogues.

pub fn info(config: Toml) -> Result(String, Snag)

Results in formatted information about rad on success, or a Snag on failure.

pub fn new() -> Dict(List(String), Task(Result(String, Snag)))

Returns a new, empty Workbook.

pub fn section(
  named name: String,
  when cond: Bool,
  enum items: List(a),
  with format_fun: fn(a) -> #(String, String),
  styled style: Dict(String, List(String)),
  sorted order_by: fn(String, String) -> Order,
) -> Option(String)

Returns Some help section, with a heading name, and items sorted and formatted into two columns, when the given cond is True, otherwise None.

The help function uses section to enumerate and document a Task’s additional usage parameters, flags, and any subtasks of the Task in question.

pub fn task(
  into workbook: Dict(List(String), Task(Result(String, Snag))),
  add task: Task(Result(String, Snag)),
) -> Dict(List(String), Task(Result(String, Snag)))

Returns a new Workbook with the given Task inserted.

Note that if a Task is added with an existing path, it will replace the Task that was already there.

pub fn tasks(
  into workbook: Dict(List(String), Task(Result(String, Snag))),
  add tasks: List(Task(Result(String, Snag))),
) -> Dict(List(String), Task(Result(String, Snag)))

Returns a new Workbook with the given list of Tasks inserted.

Note that if a Task is added with an existing path, it will replace the Task that was already there.

pub fn to_tasks(
  workbook: Dict(List(String), Task(Result(String, Snag))),
) -> List(Task(Result(String, Snag)))

Converts a Workbook into a list of Tasks.

Search Document