mamba library
The public API for defining and executing Mamba command-line applications.
Mamba keeps command definition, validation, and execution separate:
- Commands register names, descriptions, inputs, and behavior.
- An Executor builds a CommandRegistry that organizes that data.
- A Parser reads the selected registry and decides whether an invocation is valid, producing typed values when it is.
- The executor selects the matching command and gives it parsed values, trailing arguments, and global context established by hooks.
See README.md for the complete input syntax, rendered help, and
production and test setup guidance.
Classes
-
AccessorChoiceOption<
T extends Enum> - AccessorDoubleOption
- AccessorIntOption
- AccessorListOption
- AccessorOption
- A value or a group of values inside an accessor tree.
-
AccessorPrimitiveOption<
T> - AccessorStringOption
- BoolConfigurable
- A configurable boolean field rendered as a confirm prompt.
- BooleanFlag
- CarapaceSpecConverter
- Converts a typed registry record into a Carapace completion spec.
- CarapaceSpecWriter
- Writes a record-derived Carapace spec to the platform's spec directory.
- Chalk
- Chalk - A Library for printing styled text to the console using ANSI control sequences. Documentation of the ANSI code system: https://en.wikipedia.org/wiki/ANSI_escape_code . References with detailed explainations of the various color models included here: https://en.wikipedia.org/wiki/HSL_and_HSV and https://en.wikipedia.org/wiki/HWB_color_model The complete history of the X11 color names (later used in css/svg also) https://en.wikipedia.org/wiki/X11_color_names .
- ChoiceItem
-
Defines the content for a
choiceSelectorcard. -
ChoiceOption<
T extends Enum> -
ChoicePositional<
T extends Enum> -
ChoiceVariadic<
T extends Enum> - Command
- CommandEntry
- Represents a command exposed through the palette.
- CommandHelp
- The formatter and the registry an Executor resolved an invocation to.
- CommandRegistry
- CommandResolution
- CompletionCommand
- ConfigFactory
- Shorthand factory for creating Configurable fields.
- ConfigResult
- Result returned by the config editor after the user confirms.
-
Configurable<
T> - Base class for all configurable fields in a config editor.
- CountFlag
- DartTerminal
- Default Terminal implementation using dart:io stdin/stdout.
- DartTerminalInput
- Default TerminalInput implementation using dart:io stdin.
- DartTerminalOutput
- Default TerminalOutput implementation using dart:io stdout.
-
DefaultedAccessorOption<
T> -
DefaultedInput<
T> -
DefaultedOption<
T> -
DefaultedPositional<
T> -
DefaultedRepeatableOption<
T> -
DefaultValue<
T> -
DiscretionaryPositional<
T> - DisplayFeatures
- Display feature flags controlling presentation behavior.
- DoubleOption
- EnumConfigurable
- A configurable field that selects from a fixed set of string options.
- Executor
-
Flag<
T> - FlowBuilder
- Builds and runs a synchronous Terminice flow.
- FlowContext
- Read-only view of values collected by earlier flow steps.
- FlowProgressOptions
- Progress display options used by FlowBuilder.progress.
- FlowResult
- Result returned after a flow confirms or cancels.
- FlowReviewOptions
- Review screen options used by FlowBuilder.review.
- FlowSummaryItem
- Summary metadata for a collected flow value.
- GroupCommand
- GroupConfigurable
- A configurable that groups child fields into a nested editor.
- GroupHelp
- A resolved help page supplied to a group that has no selected child.
- HelpDoc
- Represents a single searchable help document.
- HelpFormatter
- The customization boundary for rendering a CommandRegistry as help text.
- InlineProgressBar
- Theme-aware inline progress indicator meant for log-style updates.
- InlineSpinner
- Minimal spinner intended for inline log output.
-
Input<
T> - An identity-based, typed handle for a parsed command value.
- InputDefinition
- Metadata used by the parser, registry, help, and completion integrations.
- IntOption
- LoadingSpinner
- Theme-aware loading spinner with multiple visual styles.
- MambaBuiltInFlags
- Reusable flag declarations supplied by Mamba.
- MambaColors
- MambaContext
- Mutable state scoped to an executor and shared by all of its executions.
- MambaContextBool
- A bool value stored in MambaContext.
- MambaContextDouble
- A double value stored in MambaContext.
- MambaContextInt
- An int value stored in MambaContext.
-
MambaContextKey<
T extends Object> - A typed identity token for a scalar value stored in MambaContext.
- MambaContextString
- A String value stored in MambaContext.
-
MambaContextValue<
T extends Object> - A closed scalar value that can be stored in MambaContext.
- MambaEnumValue
-
Opt in to exact enum-owned CLI choice spellings instead of
Enum.name. - MambaExecutionError
- MambaExecutionResult
-
MambaExecutor<
T> - MambaFailureResult
- MambaHelpFormatter
- Renders a CommandRegistry as ANSI-styled command-line help text.
- MambaReadContext
- A read-only view of a MambaContext supplied to ordinary command hooks.
- MambaSuccessResult
-
MandatoryPositional<
T> - NormalPositional
- NormalVariadic
- NumberConfigurable
- A configurable numeric field with optional slider mode.
-
Option<
T> -
OptionalInput<
T> -
OptionalPositional<
T> -
PairChoiceOption<
T extends Enum> - PairDoubleOption
-
PairedOptions<
T extends Object> - A group whose members must either all be supplied or all be omitted.
- PairedOptionsDefinition
- PairIntOption
-
PairOption<
T> - PairStringOption
- ParsedInputs
-
ParsedValue<
T> - Parser
- Parses one command line into identity-keyed typed input values.
- PasswordConfigurable
- A configurable password/secret field with masked display.
-
Positional<
T> - ProcessedStandardInput
- Data read from the invocation's standard input.
- ProgressBar
- Themed progress bar for displaying determinate progress.
- ProgressDots
- Frame-based dots indicator for ambient progress feedback.
- PromptTheme
- Rich styling bundle composing colors, glyphs, and display features.
- RangeConfigurable
- A configurable dual-handle range field.
- RangeValue
- Internal pair to hold the two endpoints of a range.
- RatingConfigurable
- A configurable star-rating field.
- RegistryAccessor
- RegistryAccessorGroup
- RegistryAccessorValue
- RegistryCommand
- RegistryRecordConverter
- Converts a typed registry description into an integration-specific artifact.
-
RepeatableChoiceOption<
T extends Enum> - RepeatableDoubleOption
- RepeatableIntOption
-
RepeatableOption<
T> - RepeatableOptionDefinition
- RepeatablePairDoubleOption
- RepeatablePairIntOption
-
RepeatablePairOption<
T> - RepeatablePairStringOption
- RepeatableStringOption
-
RepeatedChoicePositional<
T extends Enum> -
RepeatedPositional<
T> - RepeatedPositionalDefinition
- RepeatedStringPositional
-
RequiredAccessorOption<
T> -
RequiredInput<
T> -
RequiredOption<
T> -
RequiredRepeatableOption<
T> -
SelectedOptions<
T extends Object> - A named collection of pair options that resolves to a map of supplied values.
-
SingleOption<
T> - StringConfigurable
- A configurable string field using a text or multiline prompt.
- StringOption
- TaskProgress
- Mutable progress state passed to AsyncTaskExtensions.progressTask.
- Terminal
- Abstract terminal interface for I/O operations.
- TerminalColors
- Color palette for terminal output using ANSI escape sequences.
- TerminalContext
- Global context for accessing the current Terminal instance.
- TerminalEnvironment
- Optional environment capabilities exposed by a Terminal.
- TerminalGlyphs
- Glyph set for structural terminal elements.
- TerminalInput
- Abstract input interface for terminal operations.
- TerminalOutput
- Abstract output interface for terminal operations.
- Terminice
- Fluent theme-aware builder that exposes every prompt as an extension method.
-
TerminiceComponent<
T> - A reusable custom component that runs against a configured Terminice.
- TerminiceComponentContext
- Execution context for a custom TerminiceComponent.
- TerminiceConfig
- Immutable configuration shared by a Terminice instance.
- ThemeConfigurable
- A configurable that lets the user pick a PromptTheme from a list.
- ToBashCompletionConverter
- Compiles a registry record into a portable Bash completion script.
- ToFishCompletionConverter
-
Compiles a registry record into Fish
completedeclarations. - ToggleItem
- Represents a single row in a toggle group.
- ToPowerShellCompletionConverter
- Compiles a registry record into a native PowerShell argument completer.
- ToZshCompletionConverter
- Compiles a registry record into a native Zsh completion function.
- Variadic
- YamlWriter
- YAML Writer.
- YamlWriterConfig
- Configuration for YamlWriter.
Enums
- BadgeTone
- Semantic badge tones shared by style-aware components.
- ChalkAnsiColorSet
- Color sets available for the basic ANSI colors 0 - 15. These match the colors I used for DartPad and VSCode also. There are versions for light mode, dark mode and high contrast mode.
- ChalkOutputMode
-
Available output modes for the color and styled text. The default is
ANSI output mode,
setOutputMode()can be used on specific Chalk instances to change this. `Chalk.setDefaultOutputMode = true | false;' can be used to change the default for future construction of Chalk instances. The default is ChalkOutputMode.ansi - ChalkWhitespaceTreatment
- FlowProgressStyle
- Progress display styles supported by flow metadata.
- HintStyle
- Hint display style options for keyboard bindings.
- MambaExecutionPhase
- QuoteStyle
- Style of quotes to use for string serialization.
- RegistryValueKind
- ShellCompletion
- SpinnerStyle
- Available visual styles for spinners and shimmer effects.
- TaskDisplay
- Rendering mode used by AsyncTaskExtensions.task and progress helpers.
- TaskFinalBehavior
- Controls what remains on screen when a task finishes.
- TaskRunningIndicator
- Running indicator used by inline task renderers.
- TerminalCompatibility
- Broad terminal capability levels for adapting prompt themes.
- TerminiceExecutionMode
- The effective way a built-in Terminice component should execute.
- TerminiceFallbackMode
- Policy for choosing built-in rich, line-oriented, or unattended execution.
Mixins
-
ChoiceValidated<
T extends Enum> - HookRunner
-
NumericRangeValidated<
T extends num> - NumericStepValidated
- PersistentHookRunner
- RegExpValidated
Extension Types
- EntryDescriptionString
- A yellow description for a help entry.
- FormattedString
- An ANSI-styled fragment that a help formatter can compose safely.
- OptionalString
- A styled help fragment enclosed in optional square brackets.
- OrString
- Joins mutually exclusive alternatives.
- PairString
- Joins members that must be supplied together.
- RequiredString
- A styled help fragment that must be supplied.
- SectionTitleString
- A green title for a help section.
- SelectionString
- Joins members that can be selected independently.
Extensions
- AsyncTaskExtensions on Terminice
- Adds high-level async task rendering to Terminice.
- ChalkX11 on Chalk
-
This extension class adds proper methods to Chalk for all of the
standard X11/CSS/SVG color names for use by Chalk.
This extension has the added advantage of providing code completion and type
checking at coding/compile time. Using the dynamic color method cannot provide
any coding/compile time checks because it works via a dynamic lookup at run time.
Example of using this extension for Chalk:
chalk.lightGoldenrodYellow.onCornflowerBlue(...)versus having to use thecolor(orcssorx11) method to get adynamicso you can use the dynamic lookups:chalk.color.lightGoldenrodYellow.onCornflowerBlue(...)Because of the dynamic lookup is not resolved until run time that method can be prone to errors which would not be detected until run time. - CheatSheetExtensions on Terminice
- Provides the cheatSheet method for rendering reference tables.
- CheckboxSelectorExtensions on Terminice
-
Extension providing the checkboxSelector prompt for
Terminice. - ChoiceSelectorExtensions on Terminice
-
Extension providing the choiceSelector prompt for
Terminice. - ColorPickerPromptExtensions on Terminice
-
Keyboard-first
colorPickerprompt for Terminice. - CommandPaletteExtensions on Terminice
-
Extension providing the commandPalette prompt for
Terminice. - ConfigEditorExtensions on Terminice
- Config editor that presents a themed, searchable list of configurable fields and lets the user edit each one using the appropriate prompt.
- ConfigFactoryExtension on Terminice
- Provides config as a shorthand factory for creating configurables.
- ConfirmPromptExtensions on Terminice
- Accessible confirm prompt with themed buttons and sensible default focus.
- DatePickerExtensions on Terminice
- Adds the datePicker method to Terminice for interactive calendar-based date selection.
- DatePromptExtensions on Terminice
-
Adds the production-grade, keyboard-first
dateprompt toTerminice. - FilePickerExtensions on Terminice
- Adds the filePicker method to Terminice for interactive file browsing.
- FormPromptExtensions on Terminice
- Multi-field text input form rendered inside a single themed frame.
- GridSelectorExtensions on Terminice
- Generic 2D grid selector with arrow-key navigation.
- HelpCenterExtensions on Terminice
- Provides the helpCenter method for interactive documentation.
- HotkeyGuideExtensions on Terminice
- Provides the hotkeyGuide method for documenting keyboard shortcuts.
- InlineProgressBarExtensions on Terminice
- Adds the inlineProgressBar method to the Terminice instance.
- InlineSpinnerExtensions on Terminice
- Adds the inlineSpinner method to the Terminice instance.
- LoadingSpinnerExtensions on Terminice
- Adds the loadingSpinner method to the Terminice instance.
- MultiLineInputPromptExtensions on Terminice
- Multi-line editor prompt that emulates a lightweight terminal text area with scrolling, cursor management, and full keyboard bindings.
- PasswordPromptExtensions on Terminice
- Password prompt with masking, optional reveal toggle, and theme-aware status hints.
- PathPickerExtensions on Terminice
- Adds the pathPicker method to Terminice for interactive directory and file selection.
- ProgressBarExtensions on Terminice
- Adds the progressBar method to the Terminice instance.
- ProgressDotsExtensions on Terminice
- Adds the progressDots method to the Terminice instance.
- PromptThemeCompatibility on PromptTheme
- Applies TerminalCompatibility to a PromptTheme.
- RangePromptExtensions on Terminice
- Dual-handle range prompt for selecting a numeric or percentage span.
- RatingPromptExtensions on Terminice
- Star rating prompt with gradient stars, optional labels, and numeric shortcuts.
- RegistryPositionalCardinality on RegistryPositional
- SearchSelectorExtensions on Terminice
- Presents a filterable list with optional multi-select controls.
- SliderPromptExtensions on Terminice
- Interactive slider prompt for continuous value selection with a theme-aware bar renderer.
- SpinnerStyleExtensions on SpinnerStyle
- Extension methods for SpinnerStyle to provide string representations.
- TagSelectorExtensions on Terminice
-
Extension providing the tagSelector prompt for
Terminice. - TerminiceComponentRunner on Terminice
- Shared execution helper for high-level Terminice components.
- TerminiceFlowExtensions on Terminice
- Flow helpers for running a sequence of synchronous Terminice steps.
- TerminiceMessageExtensions on Terminice
- Adds small synchronous message primitives to Terminice.
- TextPromptExtensions on Terminice
- Text input prompt with placeholder support, inline validation, and clear control hints that render cleanly on pub.flutter-io.cn.
- ThemeDemoExtensions on Terminice
- Provides the themeDemo method for previewing bundled themes.
- ThemeExtensions on Terminice
- Fluent theme-aware builder that exposes every prompt as an extension method.
- ToggleGroupExtensions on Terminice
-
Extension providing the toggleGroup prompt for
Terminice.
Constants
-
builtInThemes
→ const Map<
String, PromptTheme> - Built-in theme presets mapped by name.
- DUMP_HTML_INFO_OBJECTS → const bool
Properties
- ansiColorDisabled → bool
-
Read only. Chalk does not look at it's value.
final
- chalk ↔ Chalk
-
Default global instance of chalk used for base call.
This can be set to a specific Chalk instance that would then serve
as basis for all calls.
getter/setter pair
- chalkUsedAnsiInclude → String
-
Read only, informational only.
Name of the ansi include file used
supports_ansi.dartis the default, or the dart.libary.io versionsupports_ansi_io.dartor the dart.library.js_interop versionsupports_ansi_web.dart.final - dartSupportsAnsiColor → bool
-
Read only. Chalk does not use it's value although in some
situation a user might use this to set the Chalk ansi color level
(or something) I have left it here only for completeness.
Within the common debug consoles this variable is essentially
worthless because they return FALSE from both VSCode debug console
and IntelliJ/Android Studio debug consoles.
(This is because dart just checks for 'xterm' string being present in
the 'TERM' environmental variable of the console..)
See https://github.com/dart-lang/sdk/issues/31606 and
https://github.com/dart-lang/sdk/issues/41770 for more info.
final
- terminice → Terminice
-
Global entry point for the default Terminice client using
PromptTheme.dark and the default DartTerminal.
final
Functions
-
isClosedPipeFileSystemException(
FileSystemException error) → bool -
valueKindOf(
InputDefinition input) → RegistryValueKind - One interpretation of an input's value across parsing and registry output.
Typedefs
- CompletionFileWriter = void Function(String path, String contents)
- Receives a validated destination and the completion script generated for it.
- FlowCondition = bool Function(FlowContext context)
- Decides whether a flow step should run.
-
FlowStepRunner<
T> = T? Function(FlowContext context) - Runs a custom flow step and returns its value.
-
FlowSummary<
T> = String Function(T value, FlowContext context) - Builds a review summary string for a completed flow step value.
- FlowTemplate = void Function(FlowBuilder flow)
- Adds reusable steps to a FlowBuilder.
-
FlowValidator<
T> = String? Function(T value, FlowContext context) - Validates a value returned by a flow step.
-
ParsedArguments
= (List<
String> , ParsedInputs, List<String> , {bool help, bool version}) - RegistryFlag = ({bool? defaultValue, String? description, bool hidden, String name, bool? negatable, String? short})
-
RegistryOption
= ({List<
String> ? choices, String? defaultValue, String? description, bool hidden, num? max, num? min, String name, List<String> ? pairedOptions, String? pattern, bool? repeatable, bool required, String? short, num? step, bool? unique, String valueType}) -
RegistryOptionGroup
= ({List<
String> members, bool required, bool single}) - One group of related options: a paired set or a selected set.
-
RegistryPositional
= ({List<
String> ? choices, String? defaultValue, String? description, String name, String? pattern, bool? repeatable, bool required, int? times}) -
RegistryRecord
= ({List<
RegistryAccessor> ? accessors, List<RegistryCommand> ? commands, Map<String, List< conflicts, List<String> >String> ? defaultCommandPath, String description, List<RegistryFlag> ? flags, String name, List<RegistryOptionGroup> ? optionGroups, List<RegistryOption> ? options, List<RegistryFlag> ? persistentFlags, List<RegistryOption> ? persistentOptions, List<RegistryPositional> ? positionals, RegistryVariadic? variadic}) -
RegistryVariadic
= ({List<
String> ? choices, String? description, String? pattern}) - TaskCancelPredicate = bool Function(Object error)
- Returns whether an error should be displayed as a cancellation.
- TaskErrorMessage = String Function(Object error, StackTrace stackTrace)
- Builds a failure or cancellation message from the thrown error.
-
TerminiceComponentCallback<
T> = T Function(TerminiceComponentContext context) -
Runs a custom Terminice component with a prepared component
context. - YAMLWriter = YamlWriter
Exceptions / Errors
- FlowValidationException
- Exception thrown when a flow step returns a value that fails validation.
- MambaApplicationNameException
- MambaCommandNotFoundException
- MambaException
- A recoverable failure that can be rendered to a user.
- MambaIntegrationException
- MambaParseException
- MambaRegistryError
- An unrecoverable error in a Mamba command-definition invariant.