Interactive programming (repl): Difference between revisions

Content added Content deleted
Line 1,403: Line 1,403:
=={{header|Rust}}==
=={{header|Rust}}==
This method use the crate clap: '''clap''' is used to parse and validate the string of command line arguments provided by the user at runtime. You provide the list of valid possibilities, and clap handles the rest. This means you focus on your applications functionality, and less on the parsing and validating of arguments.
This method use the crate clap: '''clap''' is used to parse and validate the string of command line arguments provided by the user at runtime. You provide the list of valid possibilities, and clap handles the rest. This means you focus on your applications functionality, and less on the parsing and validating of arguments.
* One of clap configurations is a mathod used a YAML file to build the CLI and keep the Rust source tidy or support multiple localized translations by having different YAML files for each localization.
One of clap configurations is a mathod used a YAML file to build the CLI and keep the Rust source tidy or support multiple localized translations by having different YAML files for each localization.
* First, create the cli.yaml file to hold the CLI options, but it could be called anything we like:
- First, create the cli.yaml file to hold the CLI options, but it could be called anything we like:
<lang yaml>
<lang yaml>
name: myapp
name: myapp
Line 1,424: Line 1,424:
index: 3
index: 3
</lang>
</lang>

* Then, simply add ''clap'' the ''yaml'' feature flag to your Cargo.toml.
- Then, simply add ''clap'' the ''yaml'' feature flag to your Cargo.toml.
<lang yaml>
<lang yaml>
[dependencies]
[dependencies]
clap = { version = "3.0.0-beta.2", features = ["yaml"] }
clap = { version = "3.0.0-beta.2", features = ["yaml"] }
</lang>
</lang>

* Enter this code in Rust source file
- Enter this code in Rust source file
<lang rust>
<lang rust>
#[macro_use]
#[macro_use]