Cli command parsing
Options:
- call
$this->execCommand()
- If there is no namespace
- call
$grammars[namespace]->$command()
- if there is a namespace
- call
$targets[$namespace]->$command()
- if there is a namespace
Args options:
-
command
is an argument (only forexecCommand
/ no namespace) -
$phpArg
isfalse
(do not run the command) -
$phpArg
istrue
(run the command) -
$phpArg
is a single argument appended to cli arguments (anything butfalse
) -
$phpArg
is an array of arguments. Give...
as the last cli argument - TODO
$phpArg
is an array of commands to run. Give[]
as the last cli argument.command
is prepended to each entry in the$phpArg
array - TODO
$phpArg
is an executable object+method+args. Pass!
as the last cli argument, then use_object:method arg1 arg2
like_lexer:previous docblock
So basically, we parse the namespace:command
which gets us an object + method & MAY start an arg list. Then we parse the cli command args & add them to the list.
1: Create an args list from the cli args + php args
2: Get the object + method & modify args list as needed
3: Call object + method with the final args list
Command Expansion
Add command ...
, command []
, and command // abc dogs and cats
features
- default:
command abc=>[1,2,3]
is same ascommand abc [1,2,3]
. (though arrays aren't allowed in the command shorthands. The array is a single argument) -
...
:command abc ...=>['d','e','f']
is same ascommand abc d e f
-
[]
:command abc []=>['a'=>true, 'b'=>'dog']
is same ascommand abc a true
andcommand abc b dog
-
command abc []=>['a','b']
is same ascommand abc a
andcommand abc b
-
-
//
:command abc // cats
is same ascommand abc
. The//
lets you write multiple matches, for example. -
!
:command def ! => '_lexer:previous docblock'
will callcommand def $lexer->previous('docblock')
, essentially
Directive Overrides
I don't know if this is accurate, but I think it is & once verified, these notes can be used for documentation.
- Inheritance rules:
- if raw
match
directive is first in src directive, then add it first - then add instructions from the child directive, in declared order
- then add all other instructions from the source directive, in their declared order.
- If child directive contains any keys found in source directive, then do not copy the value from the source directive. The child simply overwrites (but in the child's declared order)
- if raw