Skip to content

Breaking: Completely rework how positional arguments are handled#178

Merged
FollowTheProcess merged 8 commits intomainfrom
feat/arg-package
Nov 8, 2025
Merged

Breaking: Completely rework how positional arguments are handled#178
FollowTheProcess merged 8 commits intomainfrom
feat/arg-package

Conversation

@FollowTheProcess
Copy link
Owner

Summary

Warning

This is a large breaking change

I've completed re-worked how positional arguments work, instead of getting the raw []string passed to the Run method, I've introduced a mechanism
for declaring type-safe structs describing the positional arguments, which are then inferred using generics and parsed similar to how flags already
worked.

As a result of this:

  • I've dropped the cli.Allow option and all the argument validators as this new mechanism is much better and allows you to define exactly what
    arguments you want and what types they are
  • The signature of the function provided to cli.Run has changed from func(cmd *cli.Command, args []string) error to func(cmd *cli.Command) error
  • Raw positional arguments can still be obtained using cmd.Args()

See the updated README and the updated examples for how to change your code to match the new behaviour

Note

This is not yet complete, I still want to work out how slice types work in this new system but this is good enough for now

@FollowTheProcess FollowTheProcess added breaking Breaking Changes feature New feature or request labels Nov 8, 2025
@FollowTheProcess FollowTheProcess self-assigned this Nov 8, 2025
@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

❌ Patch coverage is 78.75000% with 85 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.06%. Comparing base (14524a0) to head (770905d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/arg/arg.go 76.41% 63 Missing and 12 partials ⚠️
command.go 79.48% 5 Missing and 3 partials ⚠️
option.go 94.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #178      +/-   ##
==========================================
- Coverage   91.50%   87.06%   -4.44%     
==========================================
  Files           5        5              
  Lines        1260     1477     +217     
==========================================
+ Hits         1153     1286     +133     
- Misses         61      129      +68     
- Partials       46       62      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@FollowTheProcess FollowTheProcess merged commit 6769943 into main Nov 8, 2025
10 of 12 checks passed
@FollowTheProcess FollowTheProcess deleted the feat/arg-package branch November 8, 2025 18:11
FollowTheProcess added a commit that referenced this pull request Dec 3, 2025
* Implement the arg.Value approach

* Hook arg up (mostly)

* Fix command tests expecting args in a different way

* Add tests for the arg parsing mechanisms

* Rename some stuff

* Hook up the help

* Update the docs

* Update some tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking Changes feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant