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

Modifying help flag names does not work for subcommands #215

Closed
2 tasks done
paulofaria opened this issue Jul 31, 2020 · 2 comments · Fixed by #251
Closed
2 tasks done

Modifying help flag names does not work for subcommands #215

paulofaria opened this issue Jul 31, 2020 · 2 comments · Fixed by #251
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@paulofaria
Copy link

paulofaria commented Jul 31, 2020

modifying-the-help-flag-names does not work for subcommands.

Possibly related to #36.

Checklist

  • If possible, I've reproduced the issue using the master branch of this package
  • I've searched for existing GitHub issues

Steps to Reproduce

struct FeatherFeed : ParsableCommand {
    static var configuration = CommandConfiguration(
        abstract: "FeatherFeed backend application.",
        subcommands: [Run.self],
        defaultSubcommand: Run.self
    )

    ...
}


extension FeatherFeed {
    struct Run : ParsableCommand {
        static var configuration = CommandConfiguration(
            abstract: "Runs the FeatherFeed application.",
            helpNames: [.long, .customShort("?")]
        )
        
        @Option(name: .shortAndLong, help: "The host the server will run on.")
        var host: String = "::1"
        
        @Option(name: .shortAndLong, help: "The port the server will run on.")
        var port: Int = 8080
    
        ...
    }
}

Expected behavior

> swift run feather-feed run --help
OVERVIEW: Runs the FeatherFeed application.

USAGE: feather-feed run [--host <host>] [--port <port>]

OPTIONS:
  -h, --host <host>       The host the server will run on. (default: ::1)
  -p, --port <port>       The port the server will run on. (default: 8080)
  -?, --help              Show help information.

Actual behavior

> swift run feather-feed run --help
OVERVIEW: Runs the FeatherFeed application.

USAGE: feather-feed run [--host <host>] [--port <port>]

OPTIONS:
  -h, --host <host>       The host the server will run on. (default: ::1)
  -p, --port <port>       The port the server will run on. (default: 8080)
  -h, --help              Show help information.

Discussion

Apparently subcommands are inheriting the helpNames configuration from the parent command. If I change helpNames for the FeatherFeed command, the Run subcommand inherits the -? flag.

@natecook1000 natecook1000 added bug Something isn't working good first issue Good for newcomers labels Jul 31, 2020
@Zoha131
Copy link
Contributor

Zoha131 commented Oct 21, 2020

@natecook1000 I have a question regarding this issue. Should Subcommands inherit helpNames from its parent if not modified? Or if not modified, helpNames for Subcommands would be -h, --help regardless how it is defined in the parent command?

@natecook1000
Copy link
Member

I would think an inheritance model would make the most sense, and would be compatible with the current system. So subcommands get whatever their super-commands have specified, unless they specify their own. I think this means that we’d need to change the property to be optional and have it default to nil, however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants