Configuration

Compile-time #defines and the bundled ANSI macros

All tuning is performed via compile-time #defines; no runtime configuration is provided. A default can be overridden by defining the corresponding macro before including the header, or by passing -D... to the compiler.

Line Buffer and Tokens

MacroDefaultEffect
TCLI_CMDLINE_MAX_LEN64Maximum number of characters that fit on the command line (excluding the null terminator). The full buffer is embedded in tcli_t, so this value directly affects the struct size.
TCLI_MAX_TOKENS12Maximum number of whitespace-separated tokens produced by the tokenizer. Lines with more tokens are rejected before the executor is invoked.

History

MacroDefaultEffect
TCLI_HISTORY_BUF_LEN512Size of the ring buffer that stores history lines. Setting it to 0 compiles history out entirely: no Up/Down, no Ctrl+r, smaller tcli_t.

Output Buffering

MacroDefaultEffect
TCLI_OUTPUT_BUF_LEN256Size of the buffer used to coalesce tcli_out writes before they reach the output callback. Setting it to 0 disables buffering; every byte is forwarded to the callback immediately.

Tab-Completion

MacroDefaultEffect
TCLI_COMPLETE1Setting to 0 compiles out tab-completion entirely (smaller binary, tcli_compl_fn_t removed).

Default Prompts

Each prompt is a string. The defaults wrap the visible text in ANSI color escapes; the same form can be used in custom prompts to retain coloring.

MacroDefaultRendered
TCLI_DEFAULT_PROMPT(TCLI_COLOR_GREEN "> " TCLI_COLOR_DEFAULT)
TCLI_DEFAULT_ERROR_PROMPT(TCLI_COLOR_RED "> " TCLI_COLOR_DEFAULT)
TCLI_DEFAULT_SEARCH_PROMPT(TCLI_COLOR_GREEN "? " TCLI_COLOR_DEFAULT)

The prompts can also be overridden at runtime via tcli_set_prompt and the corresponding setters.

tclie-Specific

MacroDefaultEffect
TCLIE_ENABLE_USERS1Compiles in users and login. Set to 0 for command-only CLIs.
TCLIE_ENABLE_USERNAMES1Enables usernames in addition to passwords. Set to 0 for password-only login (matched against any user).
TCLIE_LOGIN_ATTEMPTS3Number of incorrect password attempts before the login is rejected.
TCLIE_PATTERN_MATCH1Compiles in pattern matching. Set to 0 to reduce footprint when not used.
TCLIE_PATTERN_MATCH_MAX_TOKENSTCLI_MAX_TOKENSMaximum number of tokens considered during pattern matching. More tokens require a deeper stack depth.
TCLIE_PATTERN_MATCH_BUF_LEN64Scratch buffer used for pattern-derived tab-completion candidates.

ANSI Color and Format Macros

A set of ANSI escape constants is provided for use in prompts and command output.

Foreground Colors

MacroSample
TCLI_COLOR_BLACKSample
TCLI_COLOR_REDSample
TCLI_COLOR_GREENSample
TCLI_COLOR_YELLOWSample
TCLI_COLOR_BLUESample
TCLI_COLOR_MAGENTASample
TCLI_COLOR_CYANSample
TCLI_COLOR_WHITESample
TCLI_COLOR_BRIGHT_BLACKSample
TCLI_COLOR_BRIGHT_REDSample
TCLI_COLOR_BRIGHT_GREENSample
TCLI_COLOR_BRIGHT_YELLOWSample
TCLI_COLOR_BRIGHT_BLUESample
TCLI_COLOR_BRIGHT_MAGENTASample
TCLI_COLOR_BRIGHT_CYANSample
TCLI_COLOR_BRIGHT_WHITESample
TCLI_COLOR_DEFAULTRestores the terminal’s default foreground color.

Background Colors

MacroSample
TCLI_BG_COLOR_BLACKSample
TCLI_BG_COLOR_REDSample
TCLI_BG_COLOR_GREENSample
TCLI_BG_COLOR_YELLOWSample
TCLI_BG_COLOR_BLUESample
TCLI_BG_COLOR_MAGENTASample
TCLI_BG_COLOR_CYANSample
TCLI_BG_COLOR_WHITESample
TCLI_BG_COLOR_DEFAULTRestores the terminal’s default background color.

Text Formatting

MacroSample
TCLI_FORMAT_BOLDSample
TCLI_FORMAT_DIMSample
TCLI_FORMAT_ITALICSample
TCLI_FORMAT_UNDERLINESample
TCLI_FORMAT_RESETClears all color and formatting.

Combinations

Format and color macros concatenate, and any number can be combined:

MacrosSample
TCLI_FORMAT_BOLD TCLI_COLOR_REDSample
TCLI_FORMAT_BOLD TCLI_FORMAT_UNDERLINE TCLI_COLOR_CYANSample
TCLI_FORMAT_ITALIC TCLI_COLOR_GREENSample
TCLI_FORMAT_DIM TCLI_COLOR_YELLOWSample
TCLI_BG_COLOR_BLUE TCLI_COLOR_BRIGHT_WHITESample
TCLI_FORMAT_BOLD TCLI_BG_COLOR_WHITE TCLI_COLOR_REDSample

The constants concatenate at compile time and can be composed directly into a single string literal:

#define TCLI_DEFAULT_PROMPT \
    (TCLI_FORMAT_BOLD TCLI_COLOR_CYAN "device> " TCLI_FORMAT_RESET)

The format macros used by tclie and the help command are also overridable:

MacroDefaultRendered
TCLIE_SUCCESS_FORMATTCLI_COLOR_GREENSample
TCLIE_FAILURE_FORMATTCLI_COLOR_REDSample
TCLIE_COMMAND_FORMAT(TCLI_FORMAT_BOLD TCLI_FORMAT_UNDERLINE TCLI_COLOR_CYAN)Sample
TCLIE_USAGE_FORMATTCLI_COLOR_CYANSample
TCLIE_OPTION_FORMAT(TCLI_FORMAT_ITALIC TCLI_COLOR_CYAN)Sample

Setting any of these to an empty string removes the corresponding color or formatting from the help output, e.g. for log capture or terminals that do not render escape sequences.

The tab-completion display has two further format macros:

MacroDefaultRenderedEffect
TCLI_MATCH_FORMATTCLI_COLOR_BRIGHT_BLACKSampleFormat of the common-prefix match hint shown while completing.
TCLI_SELECTION_FORMAT(TCLI_BG_COLOR_WHITE TCLI_COLOR_BLACK)SampleFormat of the currently-selected candidate when cycling through matches.

Version

The library version is available at compile time through macros defined in tcli.h: TCLI_VERSION_MAJOR, TCLI_VERSION_MINOR, TCLI_VERSION_PATCH, and TCLI_VERSION_STR.