I should perhaps have made it clearer in the patch comment that the refactor
also changes behaviour: files completion now starts at the cwd where darcs
was invoked.
With the refactoring it is now possible to improve shell completion for
darcs in a way that takes the whole command line into account. See the
change to the replace command for an illustration. I have barely started to
use the new possibilities.
The change to the zsh completion script does not depend on the refactor but
I included it because it is thematically related.
4 patches for repository http://darcs.net/screened:
patch 4800ed861b90e94d6963ba9079725d7e6cdddeda
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date: Sun Mar 26 23:08:26 CEST 2017
* refactored shell completion support
- moved listFiles, listRegisteredFiles, listUnregisteredFiles
from Darcs.Repository to their own module Darcs.UI.Completion
- renamed them to fileArgs, knownFileArgs, unknownFileArgs
- added to that module: noArgs and prefArgs
- import and use these functions for commandGetArgPossibilities
- renamed this record member to commandCompleteArgs
- added the full command line info as extra arguments to
this member, same as for commandCommand
- re-implemented completion support functions to take difference
between original cwd and repo path into account
- incomplete: also take flags and args that are already on the
command line into account; currently only used for --boring by
unknownFileArgs; more are planned
- re-implemented the only remaining (unrelated) use of listFiles in
Darcs.UI.Command.Util
- factored expandDirs (which used listFiles) and doesDirectoryReallyExist
(which is called by expandDirs) from add command to Util
since it is shared by remove command
- use fileArgs for apply and rebase apply instead of noArgs
- use knownFileArgs for replace command (planned: do this only after the
two other args have been given)
- some small things I may have forgotten
patch 4ddee01dac242abaed1d532c94f9a105bec7f272
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date: Mon Mar 27 00:30:00 CEST 2017
* complete files for darcs replace only if 2 args are already present
patch 98802f2ac1286ea24f982f6ae647999d07a12950
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date: Mon Mar 27 01:20:09 CEST 2017
* use knownFileArgs, not noArgs, for show files
patch ad82b9f4b110df2924e1fa1fb6074c48a2cf6234
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date: Sun Mar 26 22:16:46 CEST 2017
* re-write of zsh completion script
- special case for get/clone: use built-in function _urls to get some
sensible defaults in addition to what --list-options gives us
- use _multi_parts with / as separator to improve (virtual) file completion
- use separate groups for options and other arguments
- throw out use of _wanted and _arguments: like almost all of the completion
functions support in zsh, these are tailored to provide completion when
there is no support from the command itself.
Attachments
|