-
Notifications
You must be signed in to change notification settings - Fork 83
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
Support for parameters with arguments #159
base: master
Are you sure you want to change the base?
Conversation
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 think it looks pretty good! Happy to see you pick this up, arguments with values is kind of a missing feature.
See if the comments make any sense.
@rzikm Code looks good I think. Just some clippy complaints, "feat: " missing, tests. |
Did some work on this, I am not happy with how the Anyway, it turns out this change greatly speeds up log screen because we no longer try to read the entire history :D very noticeable on Windows on large repos. I removed the -S parameter for now, and added -F instead so that it can be checked that the shape works for other arg types. |
Got nerdsniped by this, so I reworked it a bit to allow arbitrary values without need for further Should be good for another review |
@rzikm I've been busy with work recently, I'll try find some time soon to look at it. |
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 dug around a bit. I managed to remove the need to implement Clone! :) It's over at the branch altsem/value-arguments.
I had some idea that the tests could:
- Create some commits (there's a
commit
helper function). - Limit log to a number less than these commits (We've tested that limiting somewhat works).
Same with grepping:
- Create two commits, e.g. "Commit 1", "Another commit"
- Grep for "Another"
- Only one should be in the log!
I think it would be nice to flatten a few structs maybe. Could dig around a lot. But at some point I'm all for merging this into master and take it from there, it doesn't have to be perfect initially :)
src/menu.rs
Outdated
Menu::Rebase => ops::rebase::get_args(), | ||
Menu::Reset => ops::reset::get_args(), | ||
Menu::Revert => ops::revert::get_args(), | ||
Menu::Stash => ops::stash::get_args(), |
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.
Perhaps they should be called init_args
? Just to make it clear that it's creating them anew.
Thanks a lot, now it looks reasonable to me, I added some tests as asked. |
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'm generally happy with the implementation.
Just found one problem: --grep
when doing log other
.
I tried to make src/tests/log.rs
a bit more clear over at altsem/value-arguments
. Also added a test for the above.
src/tests/arg.rs
Outdated
|
||
assert_eq!(arg.value_as::<String>(), None); | ||
assert_eq!(arg.value_as::<u32>(), Some(&1u32)); | ||
} |
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.
No big deal, but.
I would put these more unit
-y tests in the same file as the implementation. (like in src/key_parser.rs
)
The tests in src/tests
used to be in tests/
as proper "integration tests".
However they were moved just to make it easier to inspect internals if really needed.
Right, this might be more tricky to fix, State.close_menu call seems to throw away the not-yet used arguments, I would have to parse the values from the [OsString] args, which I don't like. Maybe we can keep the |
edit: I do think getting rid of the Also found that grepping for something that does not match seems to cause a panic: cargo run -- -k 'l-Fxxxxxxxxx<enter>l' |
@rzikm Figured I'd share. After some digging I think I found an approach that might work.
This way we can close the prompt where appropriate (some actions don't), and after the args have been assigned to commands. My work so far: 99a75bb Heading for vacay and might continue next week :) |
Thanks, I did not have time to spend on this last couple of days, hopefully I will get to it this week so we can finally draw this to finish line. |
Was playing around with gitu and wanted to refresh some of the Rust I know. This is a very rough sketch which allows me to add arguments to flags (such as
git log -n256
or in the future forgit log -S
).It's far from optimal, or production quality, just wanted to float it out there and see if you agree with the direction I took. We can iterate from there.