#user-interface #command-line #command-line-utilities #cli-applications #cui #wtools

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.

20 breaking releases

0.23.0 Oct 30, 2024
0.21.0 Sep 5, 2024
0.19.0 Jun 29, 2024
0.15.0 Mar 26, 2024
0.1.0 Oct 1, 2021

#716 in Command-line interface

Download history 14/week @ 2024-07-25 9/week @ 2024-08-01 596/week @ 2024-08-15 130/week @ 2024-08-22 1459/week @ 2024-08-29 1017/week @ 2024-09-05 43/week @ 2024-09-12 48/week @ 2024-09-19 41/week @ 2024-09-26 1/week @ 2024-10-03 4/week @ 2024-10-10 151/week @ 2024-10-17 89/week @ 2024-10-24 78/week @ 2024-10-31 21/week @ 2024-11-07

340 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

~3.5MB
~64K SLoC