Skip to content

Unexpected missing flag argument error on git push #5103

Closed

Description

@jlkiri

Describe the bug

I'm running the command git push --force-with-lease but get the following error (which I don't get in zsh):

Error: nu::parser::missing_flag_param (https://docs.rs/nu-parser/0.60.0/nu-parser/enum.ParseError.html#variant.MissingFlagParam)

  × Missing flag argument.
   ╭─[entry #4:1:1]
 1 │ git push --force-with-lease
   ·          ─────────┬────────
   ·                   ╰── flag missing string argument
   ╰────

How to reproduce

  1. Open nu shell
  2. Navigate to some git repository and make changes
  3. git push --force-with-lease

Expected behavior

No errors

Screenshots

No response

Configuration

| key                | value                               |
| ------------------ | ----------------------------------- |
| version            | 0.60.0                              |
| build_os           | macos-x86_64                        |
| rust_version       | rustc 1.59.0 (9d1b2106e 2022-02-23) |
| rust_channel       | stable-x86_64-apple-darwin          |
| cargo_version      | cargo 1.59.0 (49d8809dc 2022-02-10) |
| pkg_version        | 0.60.0                              |
| build_time         | 2022-03-24 16:54:51 +09:00          |
| build_rust_channel | release                             |
| features           | default, trash, which, zip          |
| installed_plugins  |                                     |

Additional context

No response

Activity

  1. jlkiri commented on Apr 6, 2022

    @jlkiri
    Author

    Note that running ^git push --force-with-lease works fine.

  2. changed the title [-]Unexpected missing flag argument error[/-] [+]Unexpected missing flag argument error on git push[/+] on Apr 6, 2022
  3. elferherrera commented on Apr 6, 2022

    @elferherrera
    Contributor

    Do you have an extern completion defined for git push?

  4. jlkiri commented on Apr 6, 2022

    @jlkiri
    Author

    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
      ]
    
  5. elferherrera commented on Apr 6, 2022

    @elferherrera
    Contributor

    it seems that in the definition is asking for a string. I dont know if that is needed

  6. added
    A:completions
    on Apr 14, 2022
  7. hustcer commented on Apr 14, 2022

    @hustcer
    Contributor

    @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
       ╰────
    
  8. kubouch commented on Dec 19, 2022

    @kubouch
    Contributor

    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.

  9. kubouch commented on Dec 21, 2022

    @kubouch
    Contributor

    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.

  10. added this to the v0.74 milestone on Dec 21, 2022
  11. Hofer-Julian commented on Jan 25, 2023

    @Hofer-Julian
    Contributor

    Now, you should easily get around this easily, though.

    Could you please elaborate on that @kubouch?
    How does this need to be adapted that running git push --force-with-lease without a parameter doesn't result in an error?
    https://github.com/nushell/nu_scripts/blob/dbb0b016b95576b9658a58622645ad2c583f9d83/custom-completions/git/git-completions.nu#L111

  12. kubouch commented on Jan 25, 2023

    @kubouch
    Contributor

    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.

  13. Hofer-Julian commented on Jan 25, 2023

    @Hofer-Julian
    Contributor

    Thanks, I'll open a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:completions

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions