Skip to content

feat req: --flag arguments support under .CLI.ARGS #2462

@ShubhamTiwary914

Description

@ShubhamTiwary914

Description

Context

Passing CLI args is possible by (ref - Forwarding CLI arguments to commands ):

tasks:
  yarn:
    cmds:
      - yarn {{.CLI_ARGS}}

and called as: task yarn -- install

But there's no flag support, requiring a lot of times to hardcode as env within taskfile, or using positional arguments and mapping the flags to position within the CLI args, for example:

tasks:
  somecommand:
    cmds:
      - |
        set -- {{.CLI_ARGS}}
        arg1=$1
        arg2=$2
        echo command --flag1 "$arg1" --flag2 "$arg2" 

What can be added

Adding options under the special .CLI.ARGS variable, so something the use can be something as follows:

tasks:
  somecommand:
    cmds:
        - echo command --flag1 {{.CLI.ARGS.flag1}} --flag2 {{.CLI.ARGS.flag1}}

Makes the param passing for calling commands with multiple flags much better, not having to deal with postional args splitting, or calling scripts to deal with this logic everytime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions