NoTeX 1.0.0
A modern noteworthy LaTeX template
Loading...
Searching...
No Matches
notex::ui Namespace Reference

Functions

void set_assume_yes (bool assume_yes)
 Sets whether confirm() should answer "yes" without prompting.
bool assume_yes ()
void success (std::string_view message)
 Prints a success message, prefixed with a green checkmark, to stdout.
void warning (std::string_view message)
void error (std::string_view message)
 Prints an error message, prefixed with a red cross, to stderr.
void step (std::string_view message)
 Prints a step or progress message, prefixed with an arrow, to stdout.
void info (std::string_view message)
 Prints a plain informational message to stdout.
bool confirm (std::string_view prompt, bool default_answer=false)
 Asks the user to confirm an action.
void set_stdin_interactive_override_for_testing (std::optional< bool > is_interactive)
 Testing seam: overrides whether confirm() treats standard input as an interactive terminal.

Detailed Description

NoTeX Copyright (c) 2026 Marco Tallone Licensed under the MIT License. See LICENCE for details.

Implements the notex::ui styled terminal output and the confirmation prompt declared in notex/output.hpp.

Function Documentation

◆ assume_yes()

bool notex::ui::assume_yes ( )
Returns
Whether confirm() is currently set to assume "yes".

Definition at line 43 of file output.cpp.

Referenced by set_assume_yes().

◆ confirm()

bool notex::ui::confirm ( std::string_view prompt,
bool default_answer = false )

Asks the user to confirm an action.

When the global "assume yes" flag is set, the confirmation succeeds immediately. Otherwise, if standard input is not attached to an interactive terminal, the prompt is skipped and default_answer is returned, so that a command run non-interactively (for example from a script or from the test suite) never blocks waiting on input that will never arrive.

Parameters
promptQuestion to show the user, without a trailing "?".
default_answerAnswer used when the prompt cannot be shown, and the answer suggested to the user otherwise.
Returns
True if the user confirmed, or if default_answer applied.

Definition at line 68 of file output.cpp.

Referenced by notex::Manager::delete_scaffolding(), notex::Manager::remove_bibliography(), notex::Manager::remove_section(), notex::Manager::reset(), notex::Installer::uninstall_global(), and notex::Installer::uninstall_local().

◆ error()

void notex::ui::error ( std::string_view message)

Prints an error message, prefixed with a red cross, to stderr.

Definition at line 58 of file output.cpp.

References ansi::color::red, and ansi::reset.

Referenced by notex::Orchestrator::run().

◆ info()

void notex::ui::info ( std::string_view message)

Prints a plain informational message to stdout.

Definition at line 66 of file output.cpp.

◆ set_assume_yes()

void notex::ui::set_assume_yes ( bool assume_yes)

Sets whether confirm() should answer "yes" without prompting.

Mirrors the global --yes command-line flag: once set, every subsequent call to confirm() succeeds immediately, which is what allows destructive commands to be scripted non-interactively.

Parameters
assume_yesWhether prompts should be assumed answered "yes".

Definition at line 41 of file output.cpp.

References assume_yes().

◆ set_stdin_interactive_override_for_testing()

void notex::ui::set_stdin_interactive_override_for_testing ( std::optional< bool > is_interactive)

Testing seam: overrides whether confirm() treats standard input as an interactive terminal.

confirm()'s non-interactive fallback is normally driven by the real ::isatty() state of the process, which makes it depend on how the test binary itself happens to be invoked (piped in CI, but still attached to a real terminal when a developer runs ctest directly) — the latter would otherwise block forever waiting on input that never arrives. This override lets the non-interactive path be exercised deterministically, regardless of the real terminal state. Not meant to be called outside of tests.

Parameters
is_interactiveValue to force; std::nullopt restores the real ::isatty() check.

Definition at line 45 of file output.cpp.

◆ step()

void notex::ui::step ( std::string_view message)

Prints a step or progress message, prefixed with an arrow, to stdout.

Definition at line 62 of file output.cpp.

References ansi::color::cyan, and ansi::reset.

◆ success()

void notex::ui::success ( std::string_view message)

Prints a success message, prefixed with a green checkmark, to stdout.

Definition at line 50 of file output.cpp.

References ansi::color::green, and ansi::reset.

◆ warning()

void notex::ui::warning ( std::string_view message)