Add CLI & form interface to your program.
Switch branches/tags
Clone or download
Latest commit 5642167 Jul 28, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc Set theme's color: highlight_inactive = "light black" Mar 25, 2018
examples Fmt Jul 28, 2018
src Bump version to 0.9 Jul 28, 2018
.gitignore Add example with shell completion Mar 23, 2018
.travis.yml Add travis.yml Feb 8, 2018
CHANGELOG.md Update CHANGELOG.md Jul 28, 2018
Cargo.toml Bump version to 0.9 Jul 28, 2018
LICENSE Initial commit Feb 5, 2018
README.md Bump version to 0.9 Jul 28, 2018

README.md

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.9"

main.rs

// Example showing imagined CLI app. with two actions

#[macro_use]
extern crate clap;
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(crate_name!())
        .action(
            "action1",
            "help for action1",
            FormView::new().field(Text::new("action1-data").help("help for action1 data")),
            |v| {
                println!("user input (from closure) {:?}", v);
            },
        )
        .action(
            "action2",
            "help for action2",
            FormView::new().field(Text::new("action2-data").help("help for action2 data")),
            hdlr,
        )
        .version(crate_version!())
        .about(crate_description!())
        .author(crate_authors!())
        .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

app_basic.rs example app_ln_like.rs example app_tar_like.rs example

TODO:

  • empty forms are skipped and executed

  • .validator(OneOf || Regex::new("v\d+.\d+.\d+")).unwrap()

    • or something similiar
  • add option for prose help in widget?

  • add option for prose help in cmd-picker?

    • "path" in "rustup toolchain link -h"
    • perhaps adding new cmd is walkaround, like "link-help" which displays prose
  • reusing fields in form by cloning is stupid

  • command picker show only 5 items Oo

  • expose view's options (eg. submit_anything) on Autocomplete & Multiselect

  • reusing fields in each form, like "verbose for each form"

  • allow disabling copying (ctrl+k)

  • 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
  • more tests

  • error handling & unwraps

  • magic stuff:

    • add magic which renders form for clap (or structopt) if args missing
      • clap should distinguish data types: file, dir, other
    • add magic which works with current programs like: ls, grep, etc.