moonbitlang / moon

The build system and package manager for MoonBit
https://moonbitlang.github.io/moon/
GNU Affero General Public License v3.0
188 stars 17 forks source link

Cannot pass cli options while moon run xxx #480

Closed hackwaly closed 5 days ago

hackwaly commented 1 week ago

Bug Report

Environment

OS

Operating System: macOS

MoonBit CLI Tools Version

moon 0.1.20241115 (67c2b06 2024-11-15) ~/.moon/bin/moon
moonc v0.1.20241115+351cfb074 ~/.moon/bin/moonc
moonrun 0.1.20241115 (67c2b06 2024-11-15) ~/.moon/bin/moonrun
moon run ./src/main -- -o a.out a

Steps to Reproduce

// main.mbt
fn main {
  let usage =
    #|Usage: moonyacc [options] <input-file>
  let output_file = @ref.new("")
  let input_file = @ref.new("")
  @ArgParser.parse(
    [("--out-file", "-o", Set_string(output_file), "Output file")],
    fn(rest) { input_file.val = rest },
    usage,
    @sys.get_cli_args(),
  )
  println("Input file: \{input_file}")
  println("Output file: \{output_file}")
}

Expected Behavior

Actual Behavior

error: unexpected argument '-o' found

  tip: to pass '-o' as a value, use '-- -o'

Usage: moonrun [OPTIONS] <PATH> [ARGS]...

For more information, try '--help'.
error: failed to run

Checklist