Skip to content

Implement CLI Argument Parser#95

Merged
aatxe merged 9 commits intoluau-lang:primaryfrom
unfetchable:arg-parser
Mar 19, 2025
Merged

Implement CLI Argument Parser#95
aatxe merged 9 commits intoluau-lang:primaryfrom
unfetchable:arg-parser

Conversation

@unfetchable
Copy link
Copy Markdown
Contributor

Derived from frkcli, cc @itsfrank

Closes #83

This provides a lightweight, flexible CLI argument parser for Luau. It allows handling positional arguments, options, and flags, making it easier to build scripts that are dependent on the CLI.

@itsfrank
Copy link
Copy Markdown

itsfrank commented Feb 27, 2025

Very cool that my library was helpful!

I don't have time to look too deeply into the code, but my initial thought is that we probably want a different name than argparse

I am certain you are aware, but argparse is the standard CLI parser for python and is massively popular. It has been re-implemented in a variety of languages, some of which re-use the name.

I think that we should only opt to use that name if we are explicitly re-implementing argparse's interface as faithfully as reasonably possible in Luau.

After a quick glance it does not seem that this implementation is trying to match argparse's interface, thus I would opt for a different name to avoid confusion.

@aatxe
Copy link
Copy Markdown
Member

aatxe commented Feb 27, 2025

Yeah, that's a valid point, Frank! Maybe something like cliargs or something. I'm not really trying to name things in very "novel" ways for batteries since the point is kinda to just be boring utilities that people will almost certainly end up writing better versions of in the future.

@unfetchable unfetchable requested a review from aatxe February 28, 2025 16:55
}

type ParseInterface = typeof(cliargs)
export type ParserType = setmetatable<ParseData, ParseInterface>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type ParserType = setmetatable<ParseData, ParseInterface>
export type Parser = setmetatable<ParseData, ParseInterface>

The one that is actually exposed should have an "ordinary" type name, don't need to overcomplicate it.

@deviaze
Copy link
Copy Markdown

deviaze commented Mar 2, 2025

I'd just name it cli for simplicity.

Copy link
Copy Markdown
Member

@aatxe aatxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do the file rename and type rename myself after it's merged in, I guess.

@aatxe aatxe merged commit e6b8774 into luau-lang:primary Mar 19, 2025
3 checks passed
@unfetchable unfetchable deleted the arg-parser branch April 22, 2025 08:48
green-real pushed a commit to green-real/lute that referenced this pull request May 19, 2025
Derived from [frkcli](https://github.com/itsfrank/frkcli), cc @itsfrank

Closes luau-lang#83

This provides a lightweight, flexible CLI argument parser for Luau. It
allows handling positional arguments, options, and flags, making it
easier to build scripts that are dependent on the CLI.

---------

Co-authored-by: unfetchable <mitu@vite.global>
Co-authored-by: ariel <aweiss@hey.com>
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.

Create std library for argument parsing

4 participants