fnds_cli library

A flexible and easy-to-use CLI framework for Dart.

This library provides all the components needed to build command-line interfaces with nested commands, customizable logging, and flexible argument parsing.

Classes

ArgsAdapter
An implementation of ArgumentParser that uses the 'args' package.
ArgumentParser<T>
Interface for argument parsers in the CLI framework.
AutoWidth
A width specification that automatically adjusts to content.
BaseCommand
Base class for all commands in the CLI framework.
CliCommandRunner
A command runner for executing CLI commands.
CLIState
Base class for CLI state management.
ColoredLogFormatter
A collection of log formatters for CLI applications.
DefaultLogFormatter
Flexible logging system for CLI applications.
DetailedLogFormatter
A formatter that includes the source location in log entries.
GroupCLIState<T>
Represents a collection of selected values from a group of options.
Indicators
A class that defines the visual indicators used in CLI selection interfaces.
InteractiveFallback<T>
Configuration for an interactive fallback for a command argument.
InteractiveFallbackManager
Manages interactive fallbacks for command arguments
IntWidth
A width specification with a fixed integer value.
JsonLogFormatter
A formatter that outputs log entries in JSON format.
LogEntry
A log entry in the CLI framework.
LogFormatter
A formatter for log entries.
Logger
A logger for CLI applications.
MultipleSelectFallback<E>
Specialized fallback for multiple selection that returns a list of items.
NestedCommand
A command that can have subcommands.
PatternLogFormatter
A formatter that can be customized with a pattern.
SimpleLogFormatter
A simple formatter that only includes the message.
SingleCLIState<T>
Represents a single value state from a CLI interaction.
StateManager
Manages state for CLI interactions and provides access to stored values.
Width
Base class for width specifications in layout calculations.

Enums

InteractiveInputType
Defines the type of interactive input to use when a command fails.
LogLevel
Log levels for the CLI framework.

Properties

cliStateManager StateManager
Global state manager for CLI flags and options
final

Functions

ask<T>({String? label, dynamic error(String error)?, required String question, required T defaultValue, int width = 0, int gap = 0, bool isSecretive = false, dynamic callback(SingleCLIState<T> values)?}) → T
Prompts the user for input with a specific type and returns the validated value.
confirm({String? label, required String question, int width = 0, int gap = 0, dynamic callback(SingleCLIState<bool> values)?, Indicators indicators = const Indicators(), bool defaultValue = true}) bool
Displays a Yes/No confirmation prompt and returns a boolean result.
isInteractiveModeEnabled(ArgResults? argResults) bool
Utility function to check if interactive mode is enabled
multipleSelect<T>({String? label, List<String>? optionLabels, required String question, required List<T> options, int width = 0, int gap = 0, Indicators indicators = const Indicators(), dynamic callback(GroupCLIState<T> values)?}) List<T>
Creates a multiple selection interface that allows users to select multiple options.
select<T>({String? label, required String question, List<String>? optionLabels, required List<T> options, T? recommendedOption, int width = 0, int gap = 0, dynamic callback(SingleCLIState value)?, String recommendedText = '\x1B[38;5;240m(recommended)\x1B[0m', Indicators indicators = const Indicators()}) → T
Displays a single selection menu with various options and returns the selected value.

Exceptions / Errors

CommandError
Base class for all errors in the CLI framework.
ConfigError
Error thrown when a command fails due to a configuration issue.
IoError
Error thrown when a command encounters an input/output error.
UsageError
Error thrown when a command is used incorrectly.