Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in or
create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision |
Your text |
Line 13: |
Line 13: |
|
| |
|
| = Parsing arguments passed to pkg = | | = Parsing arguments passed to pkg = |
| One of the most intimidating parts of pkg.m is the monstrous way the parsing of arguments is done. The current mayhem is probably due to the natural evolution of the code.
| |
| the method use to parse the arguments is based on a flag system.
| |
|
| |
| We started cleaning up the parsing of options to give some structure and make pkg.m easy to extend in the future. For this we focus on encapsulation.
| |
|
| |
| == Definitions of actions, targets and modifiers ==
| |
| A typical call to pkg looks like
| |
|
| |
| pkg install -forge pkg1 pkg2 pkg3 -j4
| |
|
| |
| We can identify three types of input arguments
| |
| * Action: install
| |
| * Modifiers: -forge, -j4
| |
| * Targets: pkg1, pkg2, pk3
| |
|
| |
| So far we have defined them as follows
| |
| * Action: The first input argument and can't start with a hyphen.
| |
| * Modifier: Must start with a hyphen.
| |
| * Target: Anything that is not an action nor a modifier
| |
|
| |
| == Dispatching ==
| |
|
| |
|
| Each action has its own set of valid modifiers and behaves accordingly, that is the function ''pkg'' does not parse targets nor modifiers. Therefore the rôle of the main function ''pkg'' is to call the right action once general sanity checks have been performed. | | Each action has its own set of valid modifiers and behaves accordingly, that is the function ''pkg'' does not parse targets nor modifiers. Therefore the rôle of the main function ''pkg'' is to call the right action once general sanity checks have been performed. |