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. | |
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.
| bool notex::ui::assume_yes | ( | ) |
Definition at line 43 of file output.cpp.
Referenced by set_assume_yes().
| 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.
| prompt | Question to show the user, without a trailing "?". |
| default_answer | Answer used when the prompt cannot be shown, and the answer suggested to the user otherwise. |
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().
| 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().
| void notex::ui::info | ( | std::string_view | message | ) |
Prints a plain informational message to stdout.
Definition at line 66 of file output.cpp.
| 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.
| assume_yes | Whether prompts should be assumed answered "yes". |
Definition at line 41 of file output.cpp.
References assume_yes().
| 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.
| is_interactive | Value to force; std::nullopt restores the real ::isatty() check. |
Definition at line 45 of file output.cpp.
| 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.
| 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.
| void notex::ui::warning | ( | std::string_view | message | ) |
Prints a warning message, prefixed with a yellow exclamation mark, to stdout.
Definition at line 54 of file output.cpp.
References ansi::reset, and ansi::color::yellow.
Referenced by notex::Manager::delete_scaffolding(), notex::Installer::install_global(), notex::Manager::remove_section(), notex::Manager::reset(), notex::Installer::uninstall_global(), and notex::Installer::uninstall_local().