Skip to content

Support short flag batches that take args for external completions #5923

@drbrain

Description

@drbrain

Related problem

With an extern completion for git commit:

module completions {
  export extern "git commit" [
    -a
    -m: string
  ]
}

use completions *

I want to make a fixup commit that I will git rebase -i into the proper location on my branch.

nushell complains that "Batches of short flags can't take arguments."

❯ git commit -amf
Error: nu::parser::short_flag_arg_cant_take_arg (link)

  × Batches of short flags can't take arguments.
   ╭─[entry #441:1:1]
 1 │ git commit -amf
   ·              ┬
   ·              ╰── short flag batches can't take args
   ╰────

But ^git allows this:

❯ ^git commit -amf
[drbrain/some-branch abcdef01] f
 1 file changed, 1 insertion(+)

Describe the solution you'd like

When a short flag is in trailing position it accepts arguments as git does, or sort(1) does:

❯ echo "a 2\nb 1" | ^sort -hk2
b 1
a 2
❯ echo "a 2\nb 1" | ^sort -hk1
a 2
b 1

Describe alternatives you've considered

I can work around this by adding a space between m and my message ("f")

Additional context and details

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions