-
Notifications
You must be signed in to change notification settings - Fork 17
smart interactive tab completion #308
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
base: main
Are you sure you want to change the base?
Conversation
hinting and completion for history and default commands :)
|
hmm okay the next commit is going to restructure the arguments a bit. i think it should actually be a separate pr but im just doing it all at once here. i can revert and re pr later if i need to :) |
and `Command` construction now uses the builder pattern :)
aswell as sanitising for each argument, you know also need to provide a list of hints
also fixed some minor subcmd hinting bugs
| pub(crate) struct MyHelper<'a> { | ||
| completer: FilenameCompleter, | ||
| hinter: HistoryHinter, | ||
| pub(crate) state: &'a State, |
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.
this feels very hacky. need to keep state here so we can give the Argument callbacks some program context to better hint and sanitise with.
maybe State and MyHelper should be combined? it didnt feel right to do that either though, so now theres just a reference but you have to pass a MyHelper ASWELL as a &mut State to every function that calls a command which feels veryveryvery clunky. im like 80% confident this should be changed
i was experimenting with a refcell or cow solution maybe it would be better
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.
im going to let MyHelper own State now. it could be a really bad idea but otherwise you have to clone the entire state every single tiime you run a command. untangling them should be easy if required though.
also having them together requires we pass a &mut MyHelper to exec callback which is a bit misleading since really we only want to be able to mutate the owned State
so no clone cost for executing a command. downside is that callbacks are given a `&mut MyHelper` when really we only want them to have a `&mut State` and a shared reference to the other parts of the helper. might be changed later on also multiple arguments got broken somehow. will fix soon
werid `skip` stuff, which was working without the explicit subcommand argument but now its not so :/ also hinting for out of order optional arguments is brokey now
Statebe accessed inArgumentcallbacks for some extra specifc hintingplus some other stuff
Commandnow uses the builder patternArgumenthas more stuff onw: