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

completions: suggests incorrect -e slugs when -t is used #637

Open
ee7 opened this issue Aug 4, 2022 · 2 comments
Open

completions: suggests incorrect -e slugs when -t is used #637

ee7 opened this issue Aug 4, 2022 · 2 comments
Labels
kind: bug User-facing incorrect behavior

Comments

@ee7
Copy link
Member

ee7 commented Aug 4, 2022

Each completion script cleverly suggests exercise slugs when the -e, --exercise option is used. However, they always search the current directory, even when the -t, --track-dir is used. This means that it can e.g. suggest a slug that doesn't exist in the track directory that configlet is operating on.

I guess I'll call this a "bug". Can we look at the argument of -t when completing the argument of -e?

@ee7 ee7 added the kind: bug User-facing incorrect behavior label Aug 4, 2022
@ee7 ee7 mentioned this issue Aug 8, 2022
@glennj
Copy link
Contributor

glennj commented Oct 24, 2022

Here's an example of a fish completion that respects previous args: https://unix.stackexchange.com/questions/722020/fish-completion-that-depends-on-other-flags

But as we're thinking about getting configlet itself to handle completions, this issue is no longer about fish/bash/zsh

@ee7
Copy link
Member Author

ee7 commented Oct 25, 2022

Thanks. For the fish completions I have this lying around in a branch from a couple of months ago:

function __fish_configlet_get_track_dir
  # If -t/--track-dir is on the command line, echoes its argument.
  set -l cmdline (commandline -p)
  if set -l match (string match -r -- "(-t|--track-dir) +([^ ]+)" $cmdline)
    echo $match[3]
    return 0
  else
    return 1
  end
end

which may or may not work. I didn't try the bash or zsh version, and yes, it might not be worth spending the time on, given:

But as we're thinking about getting configlet itself to handle completions, this issue is no longer about fish/bash/zsh

To others: Glenn is referring to #642 (comment).

Yes, I still think that's the most elegant way to handle completions in the long run. It means that a user can install a meta-completion script only once, and get updated completions for free every time that configlet is updated. That's very nice for a program like configlet, which is not installed by a package manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug User-facing incorrect behavior
Projects
None yet
Development

No branches or pull requests

2 participants