Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing flag argument in git aliases #493

Closed
fnuttens opened this issue May 16, 2023 · 15 comments · Fixed by #651
Closed

Missing flag argument in git aliases #493

fnuttens opened this issue May 16, 2023 · 15 comments · Fixed by #651

Comments

@fnuttens
Copy link
Contributor

Trying to load nu­­­­­_alias_git.nu fails at

export alias gcam = git commit --all --message

with

Error: nu::parser::missing_flag_param

  × Missing flag argument.
    ╭─[C:\…\nu_scripts\aliases\git\nu_alias_git.nu:47:1]
 47 │ export alias gcans! = git commit --verbose --all --signoff --no-edit --amend
 48 │ export alias gcam = git commit --all --message
    ·                                      ────┬────
    ·                                          ╰── flag missing string argument
 49 │ export alias gcsm = git commit --signoff --message
    ╰────
@amtoine
Copy link
Member

amtoine commented May 16, 2023

this looks like an issue with the completion of nushell itself to me 🤔

@TechWatching
Copy link
Contributor

Anyone suceeded to make it work or find a workaround?

@amtoine
Copy link
Member

amtoine commented Oct 16, 2023

@TechWatching
dumping

export alias gcam = git commit --all --message

into the REPL of the latest revision of Nushell appears to work 🤔

@TechWatching
Copy link
Contributor

@amtoine Yet I still have the error using 0.85.0 👉
image

In my config.nu file I am doing nu_scripts\aliases\git\git-aliases.nu *

@amtoine
Copy link
Member

amtoine commented Oct 17, 2023

@TechWatching
i'm using 0.85.1 😮

the new release of Nushell goes out in a few hours, can you please try again after updating and keep me updated? 😇

@fnuttens
Copy link
Contributor Author

@TechWatching @amtoine
Huh very strange I'm also on version 0.85.0 and I don't have this error anymore…

@amtoine
Copy link
Member

amtoine commented Oct 17, 2023

@TechWatching @amtoine Huh very strange I'm also on version 0.85.0 and I don't have this error anymore…

updates and patches come fast, i'm not really surprised 😉

@amtoine
Copy link
Member

amtoine commented Oct 17, 2023

@fnuttens
i'll go ahead and close this issue then 😌

if, after the release, any of you guys can reproduce the error again, please feel free to ping here to reopen 😊

@TechWatching
Copy link
Contributor

@amtoine still an issue with 0.86 on my windows laptop.

image

@amtoine
Copy link
Member

amtoine commented Oct 23, 2023

maybe that's a windows issue? 🤔

@fdncred
Copy link
Collaborator

fdncred commented Oct 23, 2023

It definitely works in Linux and does not work in Windows. I just confirmed with the latest main in Windows 11 and WSL Ubuntu.

@fnuttens
Copy link
Contributor Author

I'm also using Windows 11 and I don't have the bug, so I reckon it's more subtle than “just” a Windows issue.

@fdncred
Copy link
Collaborator

fdncred commented Oct 26, 2023

If I start nushell like nu -n I can do

use d:\nu_scripts\aliases\git\git-aliases.nu

without any problems. but with my normal startup, it fails. no clue why.

@fdncred
Copy link
Collaborator

fdncred commented Oct 26, 2023

It looks like it's a conflict between git-completions.nu and git-aliases.nu
image
If I use them in this order, there are no issues. I think that means that one command is overwriting another command between these two scripts.
image

@fdncred
Copy link
Collaborator

fdncred commented Oct 26, 2023

Ah, I think I figured it out. It's because of this in git-completions.nu

# Commit changes
export extern "git commit" [
  --all(-a)                                           # automatically stage all modified and deleted files
  --amend                                             # amend the previous commit rather than adding a new one
  --message(-m): string                               # specify the commit message rather than opening an editor
  --no-edit                                           # don't edit the commit message (useful with --amend)
]

So, when this tries to happen

export alias gcam = git commit --all --message

It sees that --message wants a string and pukes.

If I remove the : string it works fine but then finds the next similar problem

Error: nu::parser::missing_flag_param

  × Missing flag argument.
    ╭─[D:\nu_scripts\aliases\git\git-aliases.nu:51:1]
 51  export alias gcasm = git commit --all --signoff --message
 52  export alias gcb = git checkout -b
    ·                                 ─┬
    ·                                  ╰── flag missing string argument
 53  export alias gcd = git checkout develop
    ╰────

fdncred added a commit that referenced this issue Oct 26, 2023
This PR fixes the conflicts between git-completions.nu and
git-aliases.nu.

Prior to this PR you would see problems like this
```nushell
❯ use custom-completions\git\git-completions.nu *
❯ use aliases\git\git-aliases.nu
Error: nu::parser::missing_flag_param

  × Missing flag argument.
    ╭─[D:\nu_scripts\aliases\git\git-aliases.nu:64:1]
 64 │ export alias gco = git checkout
 65 │ export alias gcor = git checkout --recurse-submodules
    ·                                  ──────────┬─────────
    ·                                            ╰── flag missing string argument
 66 │ export alias gcount = git shortlog --summary --numbered
    ╰────
```
This is because, in this example, in git-completions.nu, there is a
custom command named `git checkout` that takes a `--recurse-submodules:
string` parameter, which means it's expecting a string. Removing the `:
string` part fixes the issue and allows the files to be sourced/used as
expected.

This seems more like a hack than a fix. I'm not sure if this behavior is
intended or not, but this PR fixes it anyway.

close #493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants