-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: completion for interactive mode #2729
Conversation
33a9740
to
4596f9b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So cool!
frontend/cli/cmd_interactive.go
Outdated
type interactiveCmd struct { | ||
} | ||
|
||
func (i *interactiveCmd) Run(ctx context.Context, k *kong.Kong, projectConfig projectconfig.Config) error { | ||
type FTLCompletion struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I said to put all the types at the top, but I'm going to slightly contradict myself 😂
It's preferable to have type followed immediately by methods. So in this case I'd put FTLCompletion + methods at the top, then interactiveCmd + methods below that, so it still works to read down the file and have seen everything.
Not a big deal though, but just for your reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is where I was going to put it, but I remembered your comment from yesterday :-) I will move it.
lastCompleted := "" | ||
lastSpace := false | ||
// We don't care about anything past pos | ||
// this completer can't handle completing in the middle of things |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I've noticed that before, it sucks a bit :( - still, better than no completion
@@ -62,3 +74,72 @@ func (i *interactiveCmd) Run(ctx context.Context, k *kong.Kong, projectConfig pr | |||
func errorf(format string, args ...any) { | |||
fmt.Printf("\033[31m%s\033[0m\n", fmt.Sprintf(format, args...)) | |||
} | |||
|
|||
func (f *FTLCompletion) Do(line []rune, pos int) ([][]rune, int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
4596f9b
to
3510a37
Compare
fixes: #2708