Skip to content

feat(alias): implement alias execution and builtin name protection#494

Merged
platinummonkey merged 2 commits into
DataDog:mainfrom
lognarly:feat/add-alias-execution
May 12, 2026
Merged

feat(alias): implement alias execution and builtin name protection#494
platinummonkey merged 2 commits into
DataDog:mainfrom
lognarly:feat/add-alias-execution

Conversation

@lognarly
Copy link
Copy Markdown
Contributor

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

  • Added apply_expansion and expand functions to src/commands/alias.rs to rewrite args before clap sees them
  • Updated src/main.rs to call commands::alias::expand after extension interception and switch cmd.get_matches() to cmd.get_matches_from(&args)
  • Added builtin guard in apply_expansion (src/commands/alias.rs:82) and set (src/commands/alias.rs:55) to reject aliases that conflict with built-in commands
  • Added docs/ALIASES.md covering storage locations, commands, expansion behavior, and examples
  • Updated CLAUDE.md documentation index to reference docs/ALIASES.md

Testing

  • test_apply_expansion_simple — verifies basic alias token replacement
  • test_apply_expansion_preserves_trailing_args — verifies extra args are appended after expansion
  • test_apply_expansion_preserves_leading_flags — verifies global flags before alias are retained
  • test_apply_expansion_no_match — verifies args are unchanged when no alias matches
  • test_set_rejects_builtin_name — verifies set returns an error for builtin command names

Related Issues

N/A


🤖 Generated with Claude Code

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>
@lognarly lognarly requested a review from a team as a code owner May 12, 2026 14:11
@platinummonkey platinummonkey added enhancement New feature or request usability labels May 12, 2026
…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 platinummonkey merged commit 2fbe19e into DataDog:main May 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request usability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants