Skip to content

Help texts from multiple modules are printed with --help #14033

@vlovgr

Description

@vlovgr

Describe the bug

When running --help on a custom command imported from a file which exports other modules, the help texts for all exported modules are printed. This behaviour is new since 0.98.0 and can currently be worked around by disabling the new IR and evaluator with $env.NU_DISABLE_IR = true.

How to reproduce

  1. Create a file module1.nu.
# Help text for module1.nu
export def main [] { "module1.nu" }
  1. Create a file module2.nu.
# Help text for module2.nu
export def main [] { "module2.nu" }
  1. Create a exports.nu file exporting both modules.
export module module1.nu
export module module2.nu
  1. Run use exports.nu *.

  2. Run module1 --help or module2 --help and the help texts for both module1 and module2 prints.

$ module1 --help
Help text for module1.nu

Usage:
  > main

Flags:
  -h, --help - Display the help message for this command

Input/output types:
  ╭───┬───────┬────────╮
   # │ input │ output │
  ├───┼───────┼────────┤
   0  any    any    
  ╰───┴───────┴────────╯

======================

Help text for module2.nu

Usage:
  > main

Flags:
  -h, --help - Display the help message for this command

Input/output types:
  ╭───┬───────┬────────╮
   # │ input │ output │
  ├───┼───────┼────────┤
   0  any    any    
  ╰───┴───────┴────────╯

$ module2 --help
Help text for module1.nu

Usage:
  > main

Flags:
  -h, --help - Display the help message for this command

Input/output types:
  ╭───┬───────┬────────╮
   # │ input │ output │
  ├───┼───────┼────────┤
   0  any    any    
  ╰───┴───────┴────────╯

======================

Help text for module2.nu

Usage:
  > main

Flags:
  -h, --help - Display the help message for this command

Input/output types:
  ╭───┬───────┬────────╮
   # │ input │ output │
  ├───┼───────┼────────┤
   0  any    any    
  ╰───┴───────┴────────╯

Expected behavior

I expect only the help text for module1 to show when module1 --help is run, and similarly for module2. This was the behaviour prior to 0.98.0, and if I set $env.NU_DISABLE_IR = true, then the expected behaviour is achieved.

Configuration

key value
version 0.98.0
major 0
minor 98
patch 0
branch
commit_hash 6e1e824
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.79.0 (129f3b996 2024-06-10)
rust_channel 1.79.0-x86_64-pc-windows-msvc
cargo_version cargo 1.79.0 (ffa9cf99a 2024-06-03)
build_time 2024-09-18 08:03:04 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash
installed_plugins query 0.98.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:help-systemRelated to help commands and our documentation system (not docs itself)status:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions