Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

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

Open
2 tasks done
epage opened this issue Dec 6, 2021 · 0 comments

Comments

@epage
Copy link
Owner

epage commented Dec 6, 2021

Issue by shivanandvp
Monday Dec 06, 2021 at 08:12 GMT
Originally opened as clap-rs/clap#3065


Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant