#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 releases (breaking)

0.15.0 Mar 26, 2024
0.13.0 Mar 15, 2024
0.5.0 Dec 21, 2023
0.3.0 Nov 4, 2023
0.1.0 Oct 1, 2021

#214 in Command-line interface

Download history 1/week @ 2023-12-17 12/week @ 2024-02-18 130/week @ 2024-02-25 469/week @ 2024-03-03 407/week @ 2024-03-10 112/week @ 2024-03-17 136/week @ 2024-03-24 132/week @ 2024-03-31

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

MIT license

375KB
5K SLoC

Module :: wca

experimentalrust-statusdocs.rsOpen 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::{ Args, 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( | args : Args, props | { println!( "= Args\n{args:?}\n\n= Properties\n{props:?}\n" ) } )
        .end()
      .command( "error" )
        .hint( "prints all subjects and properties" )
        .subject().hint( "Error message" ).kind( Type::String ).optional( true ).end()
        .routine( | args : Args | { println!( "Returns an error" ); Err( format!( "{}", 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

~2.4–3MB
~60K SLoC