Skip to content

Support rest_parameter, optional_parameter, default value of parameter - #79

Open
WindSoilder wants to merge 4 commits into
parse_flagfrom
more_on_def
Open

Support rest_parameter, optional_parameter, default value of parameter#79
WindSoilder wants to merge 4 commits into
parse_flagfrom
more_on_def

Conversation

@WindSoilder

@WindSoilder WindSoilder commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

This pr adds support for defining custom commands with custom completion, option parameter and default values, here are examples:

def foo-optional [x: int, y?: int] { [$x, $y] }
def foo-rest [x: int, ...y] { [$x, $y] }
def completion [] { [1, 2, 3] }
def foo-with-completion [--bar: int@completion, baz: int@completion] { [$bar, $baz] }

To achieve this, I stored more infomation into some variants of AstNode:

  • AstNode::FlagParam: custom_completion field
  • AstNode::PosParam: custom_completion, is_option fields
  • AstNode::RestParam: a new variant to store rest parameter information.

It's also one-to-one mapping to grammar.md.

Stack created with GitHub Stacks CLIGive Feedback 💬

@WindSoilder
WindSoilder added this pull request to stack #80 September 10, 2026 09:23
@WindSoilder WindSoilder changed the title more on def Support rest_parameter, optional_parameter, default value of parameter Sep 10, 2026
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