Skip to content

parser: implement flag definition and calling custom command with flag - #76

Closed
WindSoilder wants to merge 6 commits into
nushell:mainfrom
WindSoilder:parse_flag
Closed

parser: implement flag definition and calling custom command with flag#76
WindSoilder wants to merge 6 commits into
nushell:mainfrom
WindSoilder:parse_flag

Conversation

@WindSoilder

@WindSoilder WindSoilder commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

NOTE: it's based on #74, please do not review this before it.

This pr implement flag parsing in both definition and applying, for example:

def foo-with-flag [--bar: int = 3, --baz(-b), x, y: int] { [$bar, $baz, $x, $y] }
foo-with-flag --baz

To make it easiler to do resolving and typechecking, I splitted AstNode::Param into AstNode::PosParam and AstNode::FlagParam.

It also adresses the following:

  • allow custom command name contains dash(-), it's done by making call_name to return a list of berewords, which invokes identifier_allow_dash, it's one-to-one map to call_name and IDENTIFIER_ALLOW_DASH rules in grammar.md.
  • allow defining default parameter for flag and parameter, it's also one-to-one map to flag_parameter and partial positional_parameter.
  • allow calling command with spread operator

What's done next:

  1. support rest_parameter definition
  2. support option_parameter definition
  3. support custom_completion definition

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 this pull request may close these issues.

1 participant