Skip to content

Fix:(issue_2056) Add cmd.XXXArgs() functions for retrieving args#2088

Merged
dearchap merged 18 commits intourfave:mainfrom
dearchap:issue_2056
Apr 19, 2025
Merged

Fix:(issue_2056) Add cmd.XXXArgs() functions for retrieving args#2088
dearchap merged 18 commits intourfave:mainfrom
dearchap:issue_2056

Conversation

@dearchap
Copy link
Copy Markdown
Contributor

@dearchap dearchap commented Apr 2, 2025

What type of PR is this?

(REQUIRED)

  • feature

What this PR does / why we need it:

(REQUIRED)

Add functions to allow Args access. Two classes of functions are available on the command
one for single value arguments and one for multi value/slice

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #2056

Special notes for your reviewer:

(fill-in or delete this section)

Testing

(fill-in or delete this section)

go test -run=Test*Args

Release Notes

(REQUIRED)

New classes of accessor functions for different argument types has been added. One for single value arguments and one for multiple values/slices

- StringArg
- StringArgs
- FloatArg
- FloatArgs
- IntArg
- IntArgs
- UintArg
- UintArgs
- TimestampArg
- TimestampArgs

Only the single value arguments can have a default value. Parsing of arguments will stop at the first argument that fails either parsing or constraint mismatch

@dearchap dearchap requested a review from a team as a code owner April 2, 2025 01:01
Comment thread args_test.go Outdated
Copy link
Copy Markdown
Member

@meatballhat meatballhat left a comment

Choose a reason for hiding this comment

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

I fully admit that I mostly skimmed this! I'd love to know the answer to @Juneezee's question, too, but I don't have any blocking feedback.

Other notes:

  • I'm reminded that I'd like to make sure argument and flag types from external packages are possible.
  • The use of private members in the public ArgumentBase declarations still looks funny to me 🤔 e.g. the timestampValue in ArgumentsBase[time.Time, TimestampConfig, timestampValue]

@dearchap dearchap merged commit 103c934 into urfave:main Apr 19, 2025
9 checks passed
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.

Clarification regarding Command.Arguments property

3 participants