passToPacman now takes and argParser as a paramater. And is implemented
for the simple cases in cmd.go. Although passToPacman is now left non
working in places which still try to usr the old call format and will
need to be reimplemented.
Try to minimise the useage of os.Exit
Apart from init, os.Exit is only used once as the final function call.
Now we can ensure there are no random exits hidding in the code. We can
also allow part of the code to error and continue on while also
remembering that we did error and return non 0 when we finally do reach
the os.Exit. This comes in very handy for trying to save the vcs info
after an error and ensuring that alpmHandle.Release is always called.
Some of the yay specific operations such as:
'-Qstats' '-Cd'
Break the standard pacamn has set.
Most yay specific specific options have been moved into their own
operator:
'-Y' '--yay'
'-Qstats' -> '-Y --stats'
'--Cd' -> '-Y --cleandeps'
'--gendb' -> '-Y --gendb'
Although:
'-G'
has been kepts and and alias has been added for is:
'--getpkgbuild'
This shouldnt feel too different for most people given that yay will
default to:
'-Y'
when no operator has been specified. So calls like:
'yay --gendb'
will still work as they did.
Internally handleConfig has been partially refactored. Now all that
remians in setters for config. All flags that did anything beond setting
config have been moved to handleYay(). This means less nasty
os.Exit()'s and nicer flow control.
The usage has also been updated. The options changes have been added but
the layout has also been tweaked a bit.
Lastly on the things not done:
Man page has not been updated
Shell completion has not been updated
This will be done in further commits as the usage is not guaranteed
to stay the same between now the completion of the argument system.
Currently the foundation for a new fuller argument parsing has been implemented in
parser.go. Most of the parsing is now done through the argParser object
instead of seperate arrays for options and packages. The rest of the
code still expects the old system so I have left most of the operations
unimplemented for now until I redo it with the new system. Currently
only '-S' and number menu have any functionality for testing purposes.
This new system parses arguments fully instead of just looking for
predefined strings such as:
'-Sqi' '-Siq'.
This allows:
'-Syu', '-S -y -u', '--sync -y -u'
to all be parsed as the same.
This system tries to be as similar to pacman as possible, eventually
aming to fully wrap pacman, allowing yay to be used instead of pacman in
all instances.
The current implementation is not as strict as pacman when checking
arguments. If you pass
--someinvalidflag to yay then yay will simply ignore it. The flag should
still be passed to pacman which should then cause an error.
Although operations '-S' '-R' '-U' ect. are checked to make sure you can not
try to use two operations at once.
conflicting flags such as:
'--quiet' and '--info'
will not raise an error and which options gains precedence is depend on
the implementation.
Another minor issue which is worth noting is. Due to the way double
arguments are parsed:
'-dd' '-cc' '--deps --deps'
if you pass the long version and the short version:
'-d --deps'
yay will not realize its a double argument. Meanwhile pacman will
reconise it when yay calls pacman.
Currently there are a few things that need to be done before this new
system can be fuly released:
Reimplement all operations to use to new parsing system so that
the new system is at least as functional as the old one
Strip yay specific flags before passing them to pacman
Move parts of config into the argument system and only use
config for options that are meant to be saved to disk
Move yay specific operations into its own operator '-Y'
Update documentation to show the altered syntax