Expand description
sargs
simple arg parsing in rust
sargs
is a library that supplies a simple interface for building CLI
applications.
Getting started
to get started with sargs
just create a new Application
:
use sargs::Application;
let app = Application::new("testapp", "this is a testapp");
An Application
is the main wrapper around argument parsing. If you want
your application to have an argument you can use .add_arg()
:
use sargs::Application;
use sargs::Argument;
use sargs::ArgumentKind;
let mut app = Application::new("testapp", "this is a testapp");
app.add_arg(Argument::new(ArgumentKind::Switch, "--version", "-v", "print the version", true));
Alternatively you can also create a new Application and supply the arguments as a vector with it:
use sargs::Application;
use sargs::Argument;
use sargs::ArgumentKind;
let mut app = Application::with_args("testapp", "a testapp", vec![Argument::new(ArgumentKind::Switch, "--help", "-h", "prints help", true), Argument::new(ArgumentKind::Switch, "--version", "-v", "prints the version", true), Argument::new(ArgumentKind::Value, "--url", "", "the url to request", false)]);
for the exact definition of the parameters for the functions see the documentation.