epage / clapng

A full featured, fast Command Line Argument Parser for Rust
docs.rs/clap
Apache License 2.0
0 stars 0 forks source link

Cannot enable crate features on Rust Playground because `[package.metadata.playground]` is absent in Cargo.toml #247

Open epage opened 2 years ago

epage commented 2 years ago

Issue by shivanandvp Monday Dec 06, 2021 at 08:12 GMT Originally opened as https://github.com/clap-rs/clap/issues/3065


Please complete the following tasks

Clap Version

2.34.0

Describe your use case

Tried using a string YAML with clap on the Rust playground, but it does not run due to the yaml feature not being enabled. Here is an example code:

use clap;
use yaml_rust; // Needs the `yaml` feature

fn yaml_literal() -> &'static str {
    return r#"
    args: 
    - json:
        about: Output in the JSON format for machine readability and scripting purposes.
        long: json
        global: true
    - plain:
        about: Output plain text of the output without extra information, for machine readability and scripting purposes.
        long: plain
        global: true
    - debug:
        about: Output debug messages.
        long: debug
        global: true
    "#;
}

fn main() {
    let yaml = yaml_rust::YamlLoader::load_from_str(yaml_literal())
        .unwrap()
        .get(0)
        .unwrap();
    let app = clap::App::from_yaml(yaml);
    println!("{}", app.render_usage());
}

Describe the solution you'd like

Please add a list of features (including 'yaml') under [package.metadata.playground] section in your Cargo.toml file. Because it is currently not present, only the default features are enabled on the rust playground. That severely limits the use of clap, because there is no other way to enable crate features on the Rust Playground.

Alternatives, if applicable

None.

Additional Context

No response