Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal yaml not working #708

Closed
tvannahl opened this issue Oct 26, 2016 · 4 comments
Closed

Minimal yaml not working #708

tvannahl opened this issue Oct 26, 2016 · 4 comments
Labels
C-bug Category: Updating dependencies

Comments

@tvannahl
Copy link

I tried to replicate the first yaml example in the docs and it didn't work out as expected. This should probably get fixed, it doesn't make a good impression.

$ RUST_BACKTRACE=1 ./target/debug/minimal --help                                                                                                              :(
thread 'main' panicked at 'Failed to convert YAML value Real("1.0") to a string', /home/tvn/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.16.2/src/app/mod.rs:1398
stack backtrace:
   1:     0x563c69115f79 - std::sys::backtrace::tracing::imp::write::h00e948915d1e4c72
   2:     0x563c6911921c - std::panicking::default_hook::_{{closure}}::h7b8a142818383fb8
   3:     0x563c691184c9 - std::panicking::default_hook::h41cf296f654245d7
   4:     0x563c69118b58 - std::panicking::rust_panic_with_hook::h4cbd7ca63ce1aee9
   5:     0x563c691189b2 - std::panicking::begin_panic::h93672d0313d5e8e9
   6:     0x563c69118920 - std::panicking::begin_panic_fmt::hd0daa02942245d81
   7:     0x563c69073333 - _<clap..app..App<'a, 'a> as core..convert..From<&'a yaml_rust..yaml..Yaml>>::from::h37e3b667477dea17
                        at /home/tvn/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.16.2/src/app/mod.rs:8
   8:     0x563c6906ea0b - clap::app::App::from_yaml::hf9783d7fffaecb54
                        at /home/tvn/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.16.2/src/app/mod.rs:149
   9:     0x563c68f6652e - minimal::main::h3c17b90fce13964a
                        at /home/tvn/projects/rust/minimal/src/main.rs:8
  10:     0x563c6911f086 - __rust_maybe_catch_panic
  11:     0x563c69117c42 - std::rt::lang_start::h53bf99b0829cc03c
  12:     0x563c68f66613 - main
  13:     0x7f05031d5290 - __libc_start_main
  14:     0x563c68f5f729 - _start
  15:                0x0 - <unknown>
@kbknapp
Copy link
Member

kbknapp commented Oct 27, 2016

This is a typo in the examples! Thanks for pointing it out! The number should be enclosed in quotes.

@kbknapp kbknapp added C-bug Category: Updating dependencies P1: urgent A-docs Area: documentation, including docs.rs, readme, examples, etc... and removed A-docs Area: documentation, including docs.rs, readme, examples, etc... labels Oct 27, 2016
mvaude pushed a commit to myCrates/clap-rs that referenced this issue Oct 27, 2016
change yaml example to be consistent with its configuration

fix clap-rs#707, clap-rs#708
homu added a commit that referenced this issue Oct 28, 2016
fix(yaml-example): inconsistent args

change yaml example to be consistent with its configuration

fix #707, #708
@kbknapp
Copy link
Member

kbknapp commented Oct 28, 2016

I'm having an issue reproducing this - could you post the source you're using?

@tvannahl
Copy link
Author

I used the example that can be seen in the README.md

name: myapp
version: 1.0
author: Kevin K. <kbknapp@gmail.com>
about: Does awesome things
args:
    - config:
        short: c
        long: config
        value_name: FILE
        help: Sets a custom config file
        takes_value: true
    - INPUT:
        help: Sets the input file to use
        required: true
        index: 1
    - verbose:
        short: v
        multiple: true
        help: Sets the level of verbosity
subcommands:
    - test:
        about: controls testing features
        version: 1.3
        author: Someone E. <someone_else@other.com>
        args:
            - debug:
                short: d
                help: print debug information

The example should probably be (note the version entries):

name: myapp
version: "1.0"
author: Kevin K. <kbknapp@gmail.com>
about: Does awesome things
args:
    - config:
        short: c
        long: config
        value_name: FILE
        help: Sets a custom config file
        takes_value: true
    - INPUT:
        help: Sets the input file to use
        required: true
        index: 1
    - verbose:
        short: v
        multiple: true
        help: Sets the level of verbosity
subcommands:
    - test:
        about: controls testing features
        version: "1.3"
        author: Someone E. <someone_else@other.com>
        args:
            - debug:
                short: d
                help: print debug information

@kbknapp
Copy link
Member

kbknapp commented Oct 29, 2016

Ah ok thanks! I was looking at the examples/ directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants