[][src]Struct fui::Fui

pub struct Fui<'attrs, 'action> { /* fields omitted */ }

Top level building block of fui crate.

Methods

impl<'attrs, 'action> Fui<'attrs, 'action>[src]

pub fn new(program_name: &'attrs str) -> Self[src]

Creates a new Fui with empty actions.

pub fn action<F>(
    self,
    name: &'action str,
    help: &'action str,
    form: FormView,
    hdlr: F
) -> Self where
    F: Fn(Value) + 'static, 
[src]

Defines action by providing name, help, form, hdlr.

NOTE:

name is also translated into CLI argument, so:

  • "my-arg" is ok (only "a..z" & "-")
  • "my arg" is bad (becuase in shell space (" ") needs to be escaped)

Panics:

Panics if action name is duplicated.

pub fn run(self)[src]

Coordinates flow from action picking to handler running.

pub fn get_cli_input(self) -> Vec<String>[src]

Gets user input converted to cli-like format

pub fn build_cli_app(&self) -> App[src]

Returns automatiacally generated clap::App.

pub fn name(self, name: &'attrs str) -> Self[src]

Sets program's name.

For CLI means Clap::App::name

pub fn get_name(&self) -> &str[src]

Gets program's name.

pub fn get_about(&self) -> &str[src]

Gets program's about.

pub fn get_author(&self) -> &str[src]

Gets program's author.

pub fn get_version(&self) -> &str[src]

Gets program's version.

pub fn version(self, version: &'attrs str) -> Self[src]

Sets program's version.

For CLI means Clap::App::version

pub fn about(self, about: &'attrs str) -> Self[src]

Sets program's about.

For CLI means Clap::App::about

pub fn author(self, author: &'attrs str) -> Self[src]

Sets program's author.

For CLI means Clap::App::author

pub fn theme(self, theme: &'attrs str) -> Self[src]

Sets theme for Fui.

For details see Cursive's themes

Example:

use fui::Fui;
use fui::form::FormView;
use fui::fields::Text;

let my_theme = "
shadow = false
borders = \"simple\"
[colors]
    background = \"yellow\"
";

let app = Fui::new("program_name")
    .action(
        "action1",
        "desc",
        FormView::new().field(Text::new("action1-data")),
        |v| { println!("{:?}", v); }
    )
    .theme(my_theme);

pub fn skip_single_action(self, skip: bool) -> Self[src]

Sets value for skip_single_action

pub fn skip_empty_form(self, skip: bool) -> Self[src]

Sets value for skip_empty_form

Trait Implementations

impl<'a, '_, '_> From<&'a App<'_, '_>> for Fui<'a, 'a>[src]

Auto Trait Implementations

impl<'attrs, 'action> !Send for Fui<'attrs, 'action>

impl<'attrs, 'action> !Sync for Fui<'attrs, 'action>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> With for T[src]

fn with<F>(self, f: F) -> Self where
    F: FnOnce(&mut Self), 
[src]

Calls the given closure on self.

fn try_with<E, F>(self, f: F) -> Result<Self, E> where
    F: FnOnce(&mut Self) -> Result<(), E>, 
[src]

Calls the given closure on self.

fn with_if<F>(self, condition: bool, f: F) -> Self where
    F: FnOnce(&mut Self), 
[src]

Calls the given closure if condition == true.

impl<T> Erased for T