feat(alias): implement alias execution and builtin name protection#494
Merged
Merged
Conversation
Add runtime expansion of stored aliases so that user-defined shorthand commands are resolved to their full pup command before clap parsing. - Expand alias tokens in args before clap sees them, enabling pup <alias> to dispatch as pup <full command> - Guard set and apply_expansion against builtin command names to prevent aliases from shadowing built-in commands - Add docs/ALIASES.md covering storage locations, commands, expansion behavior, and examples - Update CLAUDE.md documentation index to reference ALIASES.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…d mut - Wrap is_builtin_command calls in alias.rs with #[cfg(not(target_arch = "wasm32"))] to match the extensions module gate - Replace `let mut args` mutation with a let-shadowing pattern in the alias expansion block so args is never declared mut on wasm32 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
platinummonkey
approved these changes
May 12, 2026
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.
Summary
Implements runtime alias expansion so user-defined shorthand commands are resolved to their full pup command before clap parses the argument list, and adds builtin name protection to prevent aliases from shadowing built-in commands.
Changes
apply_expansionandexpandfunctions tosrc/commands/alias.rsto rewrite args before clap sees themsrc/main.rsto callcommands::alias::expandafter extension interception and switchcmd.get_matches()tocmd.get_matches_from(&args)apply_expansion(src/commands/alias.rs:82) andset(src/commands/alias.rs:55) to reject aliases that conflict with built-in commandsdocs/ALIASES.mdcovering storage locations, commands, expansion behavior, and examplesCLAUDE.mddocumentation index to referencedocs/ALIASES.mdTesting
test_apply_expansion_simple— verifies basic alias token replacementtest_apply_expansion_preserves_trailing_args— verifies extra args are appended after expansiontest_apply_expansion_preserves_leading_flags— verifies global flags before alias are retainedtest_apply_expansion_no_match— verifies args are unchanged when no alias matchestest_set_rejects_builtin_name— verifiessetreturns an error for builtin command namesRelated Issues
N/A
🤖 Generated with Claude Code