Skip to content

Can't pass flags with = into script's main command #5532

Closed

Description

@hustcer

Describe the bug

Can't pass flags with = into script's main command

How to reproduce

# b.nu
def main [kernel: string, --version: string] {
    echo $kernel;
    echo $version
}

It's found that nu b.nu linux --version v5.2 works but nu b.nu linux --version=v5.2 does not work:

@hustcer ➜ tmp git(develop) $> nu b.nu linux --version v5.2
linux
v5.2

@hustcer ➜ tmp git(develop) $> nu b.nu linux --version=v5.2
Error: nu::parser::extra_positional (link)

  × Extra positional argument.
   ╭─[<commandline>:1:1]
 1 │ main "linux" "--version=v5.2"
   ·              ────────┬───────
   ·                      ╰── extra positional argument
   ╰────
  help: Usage: main {flags} <kernel>

Expected behavior

Both of them should work in the same way with the same output

Screenshots

No response

Configuration

key value
version 0.62.1
branch develop
tag
short_commit e9826233
commit_hash e98262330ebd1ef1fa7c85095cc0d887adde9b10
commit_date 2022-05-12 02:04:44 +00:00
build_os macos-x86_64
rust_version rustc 1.60.0 (7737e0b5c 2022-04-04)
rust_channel stable-x86_64-apple-darwin
cargo_version cargo 1.60.0 (d1fd9fe2c 2022-03-01)
pkg_version 0.62.1
build_time 2022-05-12 10:14:24 +08:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins gstat, query, query json, query web, query xml

Additional context

No response

Activity

  1. added
    category:bug
    on May 13, 2022
  2. added this to the v0.63.0 milestone on May 13, 2022
  3. hustcer commented on May 18, 2022

    @hustcer
    ContributorAuthor

    Can this issue be fixed before next release?

  4. merelymyself commented on May 18, 2022

    @merelymyself
    Contributor

    @hustcer - this is definitely an issue with deparse.rs. There is a simple fix, but I feel the whole system for argument parsing for functions should be overhauled in the future, almost every change to deparse.rs has introduced new problems. There was a discussion at #5492.

  5. hustcer commented on May 18, 2022

    @hustcer
    ContributorAuthor

    @merelymyself I see, thanks

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

    category:bugdeprecated:priority

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions