Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(completion): display aliases in fish completion #1782

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

vmaerten
Copy link
Member

@vmaerten vmaerten commented Sep 2, 2024

Fixes #1781

Before :
task_fish

After :
task_fish_fix

@davinkevin It would be amazing if you could test it before we release this. I test it locally with the docker container it sounds fine

@vmaerten vmaerten changed the title feat: display aliases in fish completion feat(completion): display aliases in fish completion Sep 2, 2024
@vmaerten vmaerten marked this pull request as ready for review September 2, 2024 18:36
@davinkevin
Copy link

I have the same result as you and it looks good to me!

I was surprised the completion was displayed like this, but it works like expected 😇

PS: I hope those completions will, one day, be part of the product and not volatile scripts maintained aside from the source code.

@davinkevin
Copy link

davinkevin commented Sep 2, 2024

Interesting 🤔

with this file:

version: 3

tasks:

  aaa:
    aliases:
      - bbb
      - ccc
      - ddd
    cmd: echo aaa

  bbb2: echo bbb2
  ccc: echo ccc

The completion choose bbb2 if I type task b + tab, instead of asking to choose between bbb2 and bbb. We use the "description" field of fish to display aliases, but it's some kind of useless, a description would be better 😇.

wdyt?

@@ -10,7 +10,7 @@ function __task_get_tasks --description "Prints all available tasks with their d
end

# Grab names and descriptions (if any) of the tasks
set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(aliases.*/\1\t\2/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/'| string split0)
set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(\(aliases.*\))/\1\t\2\t\3/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/'| string split0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this as a fix, but I think it would be good to move this complexity to Task itself sometime rather than relying on invoking sed. Looking at this expression gives me a headache 😆

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitive +1!

It would be simpler and more powerful. To match my previous comment, I had to do something like this:

set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(aliases: \(.*\))/\1,\3/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/' -e 's@,@\n@g' -e 's@ @@g'| string split0)
image

The result is better than the original version, but doing that with a real language is the best solution/idea!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with you, I would even argue that fish / bash / zsh does not support the same "feature" in the auto complete
As you said, we could move all complexity in our go code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested it in zsh, the behavior is the same, aliases are displayed but not "searchable"

@pd93
Copy link
Member

pd93 commented Sep 2, 2024

PS: I hope those completions will, one day, be part of the product and not volatile scripts maintained aside from the source code.

For the record. I just merged #1157 which is the first step towards this. We can now start the process of generating the scripts instead of using the templates.

@vmaerten vmaerten changed the title feat(completion): display aliases in fish completion fix(completion): display aliases in fish completion Sep 2, 2024
@vmaerten
Copy link
Member Author

vmaerten commented Sep 2, 2024

@pd93 What do you think about merging this to have  the same behavior as zsh, and, in the meantime, working on generating the scripts in golang ?

Copy link
Member

@pd93 pd93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about merging this to have  the same behavior as zsh, and, in the meantime, working on generating the scripts in golang ?

@vmaerten Yeah I'm fine with this. This change is still an improvement, even if there are still bigger changes to come.

@vmaerten vmaerten merged commit eb39dd9 into main Sep 2, 2024
14 checks passed
@vmaerten vmaerten deleted the 1781/fish-completion-with-aliases branch September 2, 2024 20:06
vmaerten added a commit that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fish completions don't report aliases
3 participants