Migrate CLI argument parsing to betteropts - #86
Open
jakub-bochenski wants to merge 1 commit into
Open
Conversation
Adapts the bin/sandcat dispatcher (module/command listing, --__complete, --completion) from the android-deps-build-config tab-completion template, adds betteropts as a submodule, and converts every libexec command to declare its flags/options/arguments through it instead of hand-rolled while/case loops. Bumps the minimum Bash version to 4.2 since betteropts requires associative arrays and declare -g. Behavioral notes: - init's --agent/--ide/--secret-provider (and its --sp alias) validate via betteropts' own type=choice/choices=, since each is a single value from a small fixed (or, for --agent, dynamically fetched) set - a genuine fit. --stacks/--features stay on custom validation since they're comma- separated multi-value fields, not a single choice; cache/rm and init/devcontainer have no choice-shaped validation to convert either. - init's --stacks/--secret-provider(/--sp)/--features need to distinguish "explicitly passed empty" from "omitted" (to skip interactive prompts), which betteropts doesn't expose directly; a small presence-scan over the raw args recovers it alongside the normal betteropts value parsing. The same reasoning shows up in test/init/init.bats: betteropts schema state is process-global, so tests that call `init` twice route both calls through `run` (which forks a subshell) to keep the first call's schema from leaking into the second. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
|
Thanks - though I'll hold off with merging this since it requires a bash update on mac, which would increase the barrier of entry for some users. But if people have other opinion, let me know :) |
Contributor
Author
|
FWIW the shell installer (#80) already has to handle |
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.
Adapts the bin/sandcat dispatcher (module/command listing, --__complete, --completion), adds betteropts as a submodule, and converts every libexec command to declare its flags/options/arguments through it instead of hand-rolled while/case loops. Bumps the minimum Bash version to 4.2 since betteropts requires associative arrays and declare -g.
Behavioral notes:
inittwice route both calls throughrun(which forks a subshell) to keep the first call's schema from leaking into the second.