Skip to content

Instantly share code, notes, and snippets.

@tylerhall
Created January 3, 2011 20:56
Show Gist options
  • Save tylerhall/763952 to your computer and use it in GitHub Desktop.
Save tylerhall/763952 to your computer and use it in GitHub Desktop.
cmd -a -b -c // Single letter flags
cmd -abc // Same as above
cmd -a foobar.jpg -bc
cmd --some-flag
cmd --another-flag=charlie // You can use an equal sign
cmd --another-flag charlie // Or not. It's up to you.
cmd -ab --bigflag=foo -c bar apricot orange
<?PHP
$args = new Args();
if($args->flag('a'))
// -a was set, so do something
if($args->flag('bigflag') == 'foo')
// --bigflag was set to 'foo'
foreach($args->args as $arg)
// Do something with each argument.
// Args will be bar, apricot, and orange.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment