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

trailing commas play badly with clap builder patterns #3166

Closed
sourcefrog opened this issue Nov 5, 2018 · 1 comment
Closed

trailing commas play badly with clap builder patterns #3166

sourcefrog opened this issue Nov 5, 2018 · 1 comment

Comments

@sourcefrog
Copy link

In this code https://github.com/sourcefrog/conserve/blob/d20687ab5f0e9cd607185e889857e8cd124d106a/src/bin/conserve.rs#L143 for example

                .subcommand(
                    SubCommand::with_name("block")
                        .about("Debug blockdir")
                        .subcommand(
                            SubCommand::with_name("list")
                                .about("List hashes of all blocks in the blockdir")
                                .arg(Arg::with_name("archive").required(true)),
                        )
                        .subcommand(
                            SubCommand::with_name("referenced")
                                .about("List hashes of all blocks referenced by an index")
                                .arg(Arg::with_name("archive").required(true)),
                        ),

There's an outer call to .subcommand() which takes a single parameter made from the SubCommand builder pattern. rustfmt always wants to add a trailing comma, I guess on the principle that I might add another parameter to subcommand() later (which isn't actually possible.)

I guess ideally it would know this is a chain of builder-style function calls, not a list...

@nrc
Copy link
Member

nrc commented Nov 5, 2018

This is correct behaviour - we always use trailing commas when arguments cover multiple lines.

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

No branches or pull requests

2 participants