-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Clap doesn't parse correctly a YAML file if 2 spaces are used (for indent) instead of 4. #965
Comments
Thanks for taking the time to report this! This should get fixed "for free" upon the move to using |
TL;DR: no bug, can be closed
my comparison script: #!/usr/bin/env ruby
require "yaml"
require 'psych'
require "pp"
puts $FILENAME
content11 = "%YAML 1.1\n---\n#{ File.read $FILENAME}"
puts content11
pp YAML.load content11
pp Psych.load content11
content12 = "%YAML 1.2\n---\n#{ File.read $FILENAME}"
begin
pp YAML.load content12
rescue Psych::SyntaxError
puts "syntax Error"
puts $!
end
begin
pp Psych.load content12
rescue Psych::SyntaxError
puts "syntax Error"
puts $!
end your example + differently indented alternatives: name: Test
version: "v0.1.0"
author: Booteille
about: Test
subcommands:
- server:
about: server related commands
subcommands2:
- server:
about: server related commands
subcommands3:
- server:
about: server related commands and it's output:
so I would argue that is is just an issue of yaml being yaml, you are just not supposed to put the child object of |
Rust Version
Affected Version of clap
Expected Behavior Summary
Clap should correctly handle YAML files where indents are made by 2 spaces instead of 4.
Actual Behavior Summary
Clap actually returns wrong output in this use case.
Steps to Reproduce the issue
Try to indent your file with 2 spaces instead of 4 and you should get a wrong result
Sample Code or Link to Sample Code
Here is the code i've written to test it:
And the resulted output of
cargo run -- -h
:Also, the output of
cargo run -- server
:Debug output
The text was updated successfully, but these errors were encountered: