Skip to content

Support Command aliases (eg. shortnames) - #185

Open
jakejohns wants to merge 1 commit into
getopt-php:masterfrom
jakejohns:feature/alias
Open

Support Command aliases (eg. shortnames)#185
jakejohns wants to merge 1 commit into
getopt-php:masterfrom
jakejohns:feature/alias

Conversation

@jakejohns

Copy link
Copy Markdown

Adds ability to register aliases for commands. I like to use longer, descriptive proper names with convenient shortcuts.

$ ./bin/user --help
Usage: ./bin/user <command> [options] [operands]

Options:
  --version      Show version information and quit
  -?, --help     Show this help and quit
  -v, --verbose  Increase verbosity

Commands:
  register  Register a user [alias: reg, init]
  password  Set or reset a users password [alias: passwd, pw]
  list      List users [alias: l, ls]


$ ./bin/user list
[... list command output]

$ ./bin/user ls
[... list command output]

Comment thread test/GetoptTest.php
$cmd2->setAliases(['t']);
$getopt = new GetOpt();

$getopt->addCOmmands([ $cmd1, $cmd2 ]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I found it. What you see can't be unseen... the O from Commands should be lowercase

@tflori

tflori commented May 24, 2026

Copy link
Copy Markdown
Member

thx for your patience 😄

I heard that is better than apologising...

thx for your contribution. I think it is an interesting addition to the code. If you would fix your typo please.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants