You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected missing flag argument error on git push #5103
Yes, I think it was generated as part of default config
export extern "git push" [
remote?: string@"nu-complete git remotes", # the name of the remote
refspec?: string@"nu-complete git branches"# the branch / refspec
--verbose(-v) # be more verbose
--quiet(-q) # be more quiet
--repo: string # repository
--all # push all refs
--mirror # mirror all refs
--delete(-d) # delete refs
--tags # push tags (can't be used with --all or --mirror)
--dry-run(-n) # dry run
--porcelain # machine-readable output
--force(-f) # force updates
--force-with-lease: string # require old value of ref to be at this value
--recurse-submodules: string # control recursive pushing of submodules
--thin # use thin pack
--receive-pack: string # receive pack program
--exec: string # receive pack program
--set-upstream(-u) # set upstream for git pull/status
--progress # force progress reporting
--prune # prune locally removed refs
--no-verify # bypass pre-push hook
--follow-tags # push missing but relevant tags
--signed: string # GPG sign the push
--atomic # request atomic transaction on remote side
--push-option(-o): string # option to transmit
--ipv4(-4) # use IPv4 addresses only
--ipv6(-6) # use IPv6 addresses only
]
@jntrnr to fix this issue we have to support set two or more types for an argument, something like this: def foo [--bar: string | bool ] {}, and set to any won't work for bool, if we set --force-with-lease: any will get another error for git push --force-with-lease:
Error: nu::parser::missing_flag_param (link)
× Missing flag argument.
╭─[entry #256:1:1]
1 │ git push --force-with-lease
· ─────────┬────────
· ╰── flag missing any argument
╰────
It is currently not possible for Nushell to support both --flag and --flag value at the same time because it is not clear whether value is a flag's argument or a positional argument. When #7527 lands, one workaround would be to simply leave out the flag.
So the #7527 does not solve it by extending the flag parsing rules because we cannot support every possible command signature parsing style used by any tool. Now, you should easily get around this easily, though.
If you have some proposals how our signature parsing rules could be extended, feel free to open a feature request.
Activity
jlkiri commentedon Apr 6, 2022
Note that running
^git push --force-with-leaseworks fine.[-]Unexpected missing flag argument error[/-][+]Unexpected missing flag argument error on git push[/+]elferherrera commentedon Apr 6, 2022
Do you have an extern completion defined for git push?
jlkiri commentedon Apr 6, 2022
Yes, I think it was generated as part of default config
elferherrera commentedon Apr 6, 2022
it seems that in the definition is asking for a string. I dont know if that is needed
hustcer commentedon Apr 14, 2022
@jntrnr to fix this issue we have to support set two or more types for an argument, something like this:
def foo [--bar: string | bool ] {}, and set toanywon't work forbool, if we set--force-with-lease: anywill get another error forgit push --force-with-lease:kubouch commentedon Dec 19, 2022
It is currently not possible for Nushell to support both
--flagand--flag valueat the same time because it is not clear whether value is a flag's argument or a positional argument. When #7527 lands, one workaround would be to simply leave out the flag.kubouch commentedon Dec 21, 2022
So the #7527 does not solve it by extending the flag parsing rules because we cannot support every possible command signature parsing style used by any tool. Now, you should easily get around this easily, though.
If you have some proposals how our signature parsing rules could be extended, feel free to open a feature request.
Hofer-Julian commentedon Jan 25, 2023
Could you please elaborate on that @kubouch?
How does this need to be adapted that running
git push --force-with-leasewithout a parameter doesn't result in an error?https://github.com/nushell/nu_scripts/blob/dbb0b016b95576b9658a58622645ad2c583f9d83/custom-completions/git/git-completions.nu#L111
kubouch commentedon Jan 25, 2023
Delete that line. It won't be checked by Nushell because we don't support this signature parsing style but you won't have errors anymore.
Hofer-Julian commentedon Jan 25, 2023
Thanks, I'll open a PR!
git-completions: Stop enforcing argument for `--force-with-lease`
git-completions: Stop checking `--force-with-lease`
git-completions: Stop enforcing argument for force-with-lease