core: restructure args parsing to allow +-prefixed args after -e#11969
Open
jcollie wants to merge 1 commit intoghostty-org:mainfrom
Open
core: restructure args parsing to allow +-prefixed args after -e#11969jcollie wants to merge 1 commit intoghostty-org:mainfrom
+-prefixed args after -e#11969jcollie wants to merge 1 commit intoghostty-org:mainfrom
Conversation
74dbd36 to
e0ef255
Compare
e0ef255 to
62653d9
Compare
mitchellh
requested changes
Mar 30, 2026
Contributor
mitchellh
left a comment
There was a problem hiding this comment.
There's a lot here so its going to take me awhile to get to this.
If there is any way to break this down into smaller atomic chunks that would help. I'm getting caught up in balancing the (1) passed in iterator (2) fallback (3) special case mix of things.
The extra 5 lines of boilerplate (array list init + 4 line defer) is also a huge code smell to me that something is funky here, but obv just a smell. I don't understand the context enough to judge it completely yet.
I'll take a look at this, just wanted to give you the status.
db3dc6f to
fe0ae2d
Compare
Previously, the argument parser would not allow `+`-prefixed args after `-e`. Depending on the situation, it would either raise an error about multiple actions found, or it would just skip the argument as if it wasn't there. In practice, it made commands like the following impossible: ``` ghostty -e hx +10 src/main.zig ``` ``` ghostty +new-window -e vim src/main.zig '+normal!10Gvz5' ``` This PR changes argument parsing so that it stops looking for actions once an argument like `-e` has been seen. It also stores a copy of the arguments with the action filtered out so that subsequent operations that parse the CLI arguments again (like individual actions do) do not need to worry about filtering out actions. This also parepares Ghostty for 0.16 a bit where the CLI arguments aren't available "at will" just by calling `std.process.argsWithAllocator`. Fixes ghostty-org#11937
|
Would this fix #12004 as well? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the argument parser would not allow
+-prefixed args after-e. Depending on the situation, it would either raise an error about multiple actions found, or it would just skip the argument as if it wasn't there. In practice, it made commands like the following impossible:This PR changes argument parsing so that it stops looking for actions once an argument like
-ehas been seen. It also stores a copy of the arguments with the action filtered out so that subsequent operations that parse the CLI arguments again (like individual actions do) do not need to worry about filtering out actions.This also parepares Ghostty for 0.16 a bit where the CLI arguments aren't available "at will" just by calling
std.process.argsWithAllocator.Fixes #11937