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

[feature] tab completion of projects and tags #23

Open
masukomi opened this issue Jan 22, 2023 · 0 comments
Open

[feature] tab completion of projects and tags #23

masukomi opened this issue Jan 22, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@masukomi
Copy link
Owner

add tab completion of projects and tags

start @project_<tab> should

  1. autocomplete the project name if there's only one match
  2. print out the list of all matching projects if more than one matches
  • in both cases hitting should make the suggestion text disappear
  • in both cases typing more should make the suggestion text disappear

the same behavior should apply to tags. eg. hey start @project +wal<tab>

Example tab-completion code via Linenoise. I'm currently unsure how to handle the printing of suggestions that then go away.

#!/usr/bin/env raku

use Linenoise;

my @commands = <help quit list get set>;

sub find-last-word(Str $line) {
	return $line.subst(/.*? \s? $<lw>=(\S+) $/, {"$<lw>"}  );
}

linenoiseSetCompletionCallback(-> $line, $c {
    my ( $last-word ) = find-last-word($line);

    for @commands.grep(/^ "$last-word" /).sort -> $cmd {
        linenoiseAddCompletion($c, $cmd);
    }
});

my $line = linenoise '> ';
# while (my $line = linenoise '> ').defined {
    say "got a line: $line";
# }

@masukomi masukomi added the enhancement New feature or request label Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant