Skip to content

[feature] Add a "flag-per-file" token #2260

@jamestalmage

Description

@jamestalmage

Is your feature request related to a problem? Please describe.

Many command line tools will accept multiple configuration/ignore files by passing multiple files, one flag per.

prettier --ignore-path /.gitignore --ignore-path /.prettierignore --ignore-path project-specific-ignore ... 

Describe the solution you'd like

It would be great to be able to use a token to just have the thing expand automatically.

fileGroups:
    prettier-ignore:
        # Global ignores in the root
        - '/.gitignore'
        - '/.prettierignore'
        # Project specific ignores
        - '.prettierignore'
        - '.gitignore'

tasks:
    format:
        command:
           - prettier
           - --config
           - '$workspaceRoot/.prettierrc'
           - '@groupFlag("--ignore-path ",  prettier-ignore)

The task would expand to:

tasks:
    format:
        command:
             - prettier
             - --config
             - '~/home/workspace/.prettierrc'
             - '--ignore-path'
             - '/.gitignore'
             - '--ignore-path'
             - '/.prettierignore'
             # and more `ignore-path` flags as needed for every file found

This would also allow individual projects to override the fileGroup and add/remove arguments to the command.

Describe alternatives you've considered

An alternative would be to provide a facility in Pkl that allows you to cycle through the found files. That does ad a barrier to adoption (and if the facility already exists to do it that way, it wasn't immediately obvious)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions