Skip to content

Join IEnumerable defaults with separator instead of space #951

@DiegoBaldassarMilleuno

Description

@DiegoBaldassarMilleuno

Source:

#:package CommandLineParser@2.9.1

using CommandLine;

return Parser.Default.ParseArguments<Opts>(args).MapResult(
	(Opts opts) => 0,
	errors => 2
);

class Opts {
    [Option("opt", Required = true, Separator = ',', Default = new[] { "AAA", "BBB", "CCC" }, HelpText = "boolean arg.")]
    public IEnumerable<string> MyOption { get; set; }
}

Output with --help:

test_cmdline 1.0.0
Copyright (C) 2026 test_cmdline

  --opt        Required. (Default: AAA BBB CCC) boolean arg.

  --help       Display this help screen.

  --version    Display version information.

Notice that the default argument's values are joined by spaces, which is misleading.
Since a separator is provided it should be used instead, so that the user could just copy-paste the resulting value directly and use it as argument. Currently there is no way to achieve this: see here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions