Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 1.98 KB

Readme.md

File metadata and controls

56 lines (44 loc) · 1.98 KB

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::*;

    let ca = CommandsAggregator::former()
    .grammar(
    [
      Command::former()
      .phrase( "echo" )
      .hint( "prints all subjects and properties" )
      .subject( "Subject", Type::String )
      .property( "property", "simple property", Type::String )
      .form(),
    ])
    .executor(
    [
      ( "echo".to_owned(), Routine::new( |( args, props )|
      {
        println!( "= Args\n{args:?}\n\n= Properties\n{props:?}\n" );
        Ok( () )
      })),
    ])
    .build();

    let args = std::env::args().skip( 1 ).collect::< Vec< String > >();
    ca.perform( args.join( " " ) ).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