Crate fui [] [src]

fui lets you build a form based user interfaces for a CLI program.

Examples

Cargo.toml

[dependencies]
fui = "0.8"

main.rs

extern crate fui;
extern crate fui;

use fui::{Fui, Value};
use fui::form::FormView;
use fui::fields::Text;

fn hdlr(v: Value) {
    println!("user input (from fn) {:?}", v);
}

fn main() {
    Fui::new()
        .action(
            "action1",
            "description",
            FormView::new().field(Text::new("action1 data").help("help for action1 data")),
            |v| {
                println!("user input (from closure) {:?}", v);
            },
        )
        .action(
            "action2",
            "description",
            FormView::new().field(Text::new("action2 data").help("help for action2 data")),
            hdlr,
        )
        .run();
}
Click me to see screen app_basic.rs example

More examples

Description

If you look at the example above you'll notice a few entities:

These components will be most frequently used building blocks, especially FormView and fields.

Here's the logic behind those components:

  • Fui is a struct which gathers your program actions
  • actions are things which program does (like, git pull, git push, etc.)
  • action includes:
    • description: this should shortly explain to user what action does
    • FormView: is a container for fields
      • fields represents data used during action execution
    • handler: is a fn/callback called after user fills the Form

Flow:

  1. user picks action (then form is shown)
  2. user submit form with data
  3. handler is called with data (point 2)

Modules

cursive

Re-export of Cursive crate.

feeders

Data providers for views with suggestion feature (like Autocomplete, Multiselect).

fields

Includes form's building blocks, fields.

form

Contains form related concetps like FormView.

utils

Various kinds of helpers.

validators

Provides data validators used by fields.

views

Contains views which are building blocks for fields.

Structs

Fui

Top level building block of fui crate

Enums

Value

Represents any valid JSON value.