Missing project/tag completion for add command in fish
Expected Behavior
Should give completion for projects/tags for add command after filling out from and to info.
Current Behavior
No completion.
Steps to Reproduce
- Type in
watson add -f '2019-08-09 22:00' -t '2019-08-09 22:01'. - Press
Tabto try and get project completion.
Possible Implementation
@andrewmeyer
I know that the start command has these 2 lines which provide this feature:
https://github.com/TailorDev/Watson/blob/699ccda13136cad7e567eaf41bae894af9f7fede/watson.fish#L178-L179
I tried using these same lines for add, but I realized the problem is that the functions __fish_watson_needs_project and __fish_watson_has_project assume that there won't be any flags after the main command (e.g. add).
This also presents a problem for start now since there is now the gap and confirm new project/tag flags. If you try to complete start with a flag after it, you get:
❯ watson start -c contains: Unknown option “-c”
~/.config/fish/completions/watson.fish (line 64):
if contains "$cmd[3]" (__fish_watson_get_projects)
^
in function “__fish_watson_has_project”
called on standard input
with parameter list “start”
in command substitution
called on standard input
contains
Synopsis
contains [OPTIONS] KEY [VALUES...]
contains: Type “help contains” for related documentation
contains: Unknown option “-c”
~/.config/fish/completions/watson.fish (line 121):
if contains $i (__fish_watson_get_projects)
^
in function “__fish_watson_needs_project”
called on standard input
with parameter list “start”
in command substitution
called on standard input
contains
Synopsis
contains [OPTIONS] KEY [VALUES...]
contains: Type “help contains” for related documentation
So, these functions would need to be rewritten somehow to account for flags and their values afterwards.
For the add command, perhaps the from and to flags should be enforced before adding the project/tags since those are required. This would enforce a structure for the command, so you can tell if project/tag completion is needed by seeing if the from/to flags are filled out already.