fui 0.8.0

Add CLI & form interface to your program.
Documentation

fui

docs.rs crates.io Build Status MIT licensed

Add CLI & form interface to your program.

Note: Use it at own risk!!

Basic example

Cargo.toml

[dependencies]
fui = "0.8"

main.rs

// Example showing imagined CLI app. with two actions

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();
}

This will make the program automatically working in 2 modes:

  1. Ready for parsing CLI arguments, like here:

    $ ./app_basic -h
    app_basic 1.0.0
    xliiv <tymoteusz.jankowski@gmail.com>
    An Example program which has CLI & form interface (TUI)
    
    USAGE:
        app_basic [SUBCOMMAND]
    
    FLAGS:
        -h, --help       Prints help information
        -V, --version    Prints version information
    
    SUBCOMMANDS:
        action1    help for action1
        action2    help for action2
        help       Prints this message or the help of the given subcommand(s)
    

    or

    $ ./app_basic action1 -h
    app_basic-action1 
    help for action1
    
    USAGE:
        app_basic action1 [OPTIONS]
    
    FLAGS:
        -h, --help       Prints help information
        -V, --version    Prints version information
    
    OPTIONS:
            --action1-data <action1-data>    help for action1 data
    
  2. Ready for getting user input from easy and discoverable TUI interface, like image below:

More examples

Here

Screens

TODO:

  • support user's history!
    • make fill-error-correct flow pleasent
  • support for piping!
  • create wrapper FileField
  • create wrapper DirField
  • ctrl+enter submits (#151)?
  • checkbox: automatic toggle on char
  • add Field.data & form on_submit returns it?
  • optimalizations
    • feeders use iterators
    • thread
  • tests
  • error handling & unwraps
  • magic stuff:
    • add magic which renders form for clap (or structopt) if args missing
    • add magic which works with current programs like: ls, grep, etc.