pub struct TuiApp<R: Runtime = CrosstermRuntime> { /* private fields */ }Expand description
TUI application entry points.
Build and run a TUI from a hand-built clap::Command.
Use crate::Tui for derive-based CLIs that want typed results.
Use TuiApp when you are already building a clap::Command by hand, or when you want
the untyped surface that returns argv or ArgMatches.
Implementations§
Source§impl TuiApp<CrosstermRuntime>
impl TuiApp<CrosstermRuntime>
Sourcepub fn from_command(command: Command) -> Self
pub fn from_command(command: Command) -> Self
Create a TUI from a hand-built clap::Command.
Source§impl<R: Runtime> TuiApp<R>
impl<R: Runtime> TuiApp<R>
Sourcepub fn with_config(self, config: TuiConfig) -> Self
pub fn with_config(self, config: TuiConfig) -> Self
Apply configuration before the TUI starts.
Sourcepub fn with_runtime<NR: Runtime>(self, runtime: NR) -> TuiApp<NR>
pub fn with_runtime<NR: Runtime>(self, runtime: NR) -> TuiApp<NR>
Replace the default runtime.
Sourcepub fn run(self) -> Result<Option<Vec<OsString>>, TuiError>
pub fn run(self) -> Result<Option<Vec<OsString>>, TuiError>
Run the TUI and return the selected canonical argv.
The returned argv is the executable token sequence. Preview and clipboard text are
rendered separately from these tokens, using POSIX shell quoting on Unix platforms and
PowerShell quoting on Windows.
Returns Ok(Some(argv)) when the user runs a valid command and Ok(None) when the
user exits without running. Validation stays inside the TUI flow, so invalid form
state is surfaced in-app rather than returned as a clap error from this method.
§Errors
Returns an error when terminal setup or event handling fails.
Sourcepub fn run_with_matches<F, E>(self, runner: F) -> Result<(), TuiError>
pub fn run_with_matches<F, E>(self, runner: F) -> Result<(), TuiError>
Run the TUI and execute a custom handler with ArgMatches.
Returns Ok(()) when the user exits without running. When the user does run, this
method reparses the selected argv with the original clap::Command before calling
the handler.
§Errors
Returns an error when terminal setup or event handling fails, when reparsing the selected argv with clap fails, or when the runner callback fails.
Auto Trait Implementations§
impl<R> Freeze for TuiApp<R>where
R: Freeze,
impl<R = CrosstermRuntime> !RefUnwindSafe for TuiApp<R>
impl<R> Send for TuiApp<R>where
R: Send,
impl<R> Sync for TuiApp<R>where
R: Sync,
impl<R> Unpin for TuiApp<R>where
R: Unpin,
impl<R> UnsafeUnpin for TuiApp<R>where
R: UnsafeUnpin,
impl<R = CrosstermRuntime> !UnwindSafe for TuiApp<R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more