#user-interface #wtools #cui #cli

wca

The tool to make CLI ( commands user interface ). It is able to aggregate external binary applications, as well as functions, which are written in your language.

16 breaking releases

0.19.0 Jun 29, 2024
0.17.0 May 30, 2024
0.15.0 Mar 26, 2024
0.5.0 Dec 21, 2023
0.1.0 Oct 1, 2021

#254 in Command-line interface

Download history 256/week @ 2024-03-16 139/week @ 2024-03-23 70/week @ 2024-03-30 5/week @ 2024-04-06 127/week @ 2024-05-11 26/week @ 2024-05-18 250/week @ 2024-05-25 65/week @ 2024-06-01 25/week @ 2024-06-08 4/week @ 2024-06-15 211/week @ 2024-06-29

246 downloads per month
Used in 4 crates (3 directly)

MIT license

360KB
4K SLoC

Module :: wca

experimental rust-status docs.rs Open in Gitpod discord

The tool to make CLI ( commands user interface ). It is able to aggregate external binary applications, as well as functions, which are written in your language.

Sample

#[ cfg( not( feature = "no_std" ) ) ]
{
    use wca::{ VerifiedCommand, Context, Type };

    fn main()
    {

      let ca = wca::CommandsAggregator::former()
      .command( "echo" )
        .hint( "prints all subjects and properties" )
        .subject().hint( "Subject" ).kind( Type::String ).optional( true ).end()
        .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end()
        .routine( | o : VerifiedCommand | { println!( "= Args\n{:?}\n\n= Properties\n{:?}\n", o.args, o.props ) } )
        .end()
      .command( "error" )
        .hint( "prints all subjects and properties" )
        .subject().hint( "Error message" ).kind( Type::String ).optional( true ).end()
        .routine( | o : VerifiedCommand | { println!( "Returns an error" ); Err( format!( "{}", o.args.get_owned::< String >( 0 ).unwrap_or_default() ) ) } )
        .end()
      .command( "exit" )
        .hint( "just exit" )
        .routine( || { println!( "exit" ); std::process::exit( 0 ) } )
        .end()
      .perform();

      let args = std::env::args().skip( 1 ).collect::< Vec< String > >();
      ca.perform( args ).unwrap();

    }
}

To add to your project

cargo add wca

Try out from the repository

git clone https://github.com/Wandalen/wTools
cd wTools
cd examples/wca_trivial
cargo run

Dependencies

~4MB
~69K SLoC