App

Struct App 

Source
pub struct App { /* private fields */ }

Implementations§

Source§

impl App

Source

pub fn add( context: impl Into<String>, flake_text: impl Into<String>, prefill_uri: Option<&str>, cache_config: CacheConfig, ) -> Self

Create a new App for the Add workflow

The workflow asks for URI first, then ID (with inferred ID as default). Optionally provide a prefill_uri if the user provided a URI on the command line.

Source

pub fn change( context: impl Into<String>, flake_text: impl Into<String>, inputs: Vec<(String, String)>, cache_config: CacheConfig, ) -> Self

Create a new App for the Change workflow

Takes a list of (id, current_uri) pairs. The current_uri is used to prefill the input field when an item is selected.

Source

pub fn remove( context: impl Into<String>, flake_text: impl Into<String>, inputs: Vec<String>, ) -> Self

Create a new App for the Remove workflow

Source

pub fn change_uri( context: impl Into<String>, flake_text: impl Into<String>, id: impl Into<String>, current_uri: Option<&str>, show_diff: bool, cache_config: CacheConfig, ) -> Self

Create a new App for the Change workflow when ID is already known

This is a single-screen variant that just asks for the new URI.

Source

pub fn select_one( context: impl Into<String>, prompt: impl Into<String>, items: Vec<String>, initial_diff: bool, ) -> Self

Create a standalone single-select App (for Pin/Unpin workflows)

Source

pub fn select_many( context: impl Into<String>, prompt: impl Into<String>, items: Vec<String>, initial_diff: bool, ) -> Self

Create a standalone multi-select App (for Update workflow)

Source

pub fn confirm(context: impl Into<String>, diff: impl Into<String>) -> Self

Create a standalone confirmation App with pre-computed diff

Source

pub fn follow( context: impl Into<String>, flake_text: impl Into<String>, nested_inputs: Vec<NestedInput>, top_level_inputs: Vec<String>, ) -> Self

Create a new App for the Follow workflow

Shows a list of nested inputs to select from, then a list of targets. nested_inputs contains the nested input paths with their existing follows info top_level_inputs are the available targets like “nixpkgs”, “flake-utils”

Source

pub fn follow_target( context: impl Into<String>, flake_text: impl Into<String>, input: impl Into<String>, top_level_inputs: Vec<String>, ) -> Self

Create a new App for the Follow workflow when input is already selected

Shows only the target selection list.

Source

pub fn from_command( command: &Command, flake_text: impl Into<String>, inputs: Vec<(String, String)>, diff: bool, cache_config: CacheConfig, ) -> Option<Self>

Create an App from a CLI Command.

This is the main entry point for creating TUI apps from parsed CLI arguments. Returns None if the command doesn’t need interactive TUI (e.g., all args provided, or it’s a non-interactive command like List).

§Arguments
  • command - The parsed CLI command
  • flake_text - The content of the flake.nix file
  • inputs - List of (id, uri) pairs representing current inputs
  • diff - Whether diff mode is enabled
  • cache_config - Cache configuration for completions
Source

pub fn show_diff(&self) -> bool

Source

pub fn screen(&self) -> &Screen

Source

pub fn context(&self) -> &str

Source

pub fn pending_change(&self) -> Change

Get the Change that would be applied based on current workflow state. Useful for testing to verify what modification the TUI would produce.

Source

pub fn pending_diff(&self) -> String

Compute the diff string for the current change against the flake text. Returns the unified diff showing what would change.

This looks at the current screen state (including list selections) to compute a live preview of what would happen.

Source

pub fn with_diff(self, show_diff: bool) -> Self

Set the initial diff mode

Source

pub fn update(&mut self, key: KeyEvent) -> UpdateResult

Source

pub fn cursor_position(&self, area: Rect) -> Option<(u16, u16)>

Source

pub fn terminal_height(&self) -> u16

Source

pub fn extract_result(self) -> Option<AppResult>

Trait Implementations§

Source§

impl Clone for App

Source§

fn clone(&self) -> App

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for App

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Widget for &App

Source§

fn render(self, area: Rect, buf: &mut Buffer)

Draws the current state of the widget in the given buffer. That is the only method required to implement a custom widget.

Auto Trait Implementations§

§

impl Freeze for App

§

impl RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnwindSafe for App

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more