-
Notifications
You must be signed in to change notification settings - Fork 129
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
Add args: --edit-page
and --edit-patch
#388
base: main
Are you sure you want to change the base?
Conversation
c54276c
to
b540fc9
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.
Thanks! In addition to the comments, the added functionality is not tested by our automated tests yet. I think the tests could run tldr --edit-page foo
with EDITOR=touch
and the custom pages dir set to some temporary directory. Then we can observe that the correct command touch /some/tmp/dir/foo.page.md
is run by checking whether the file exists or not.
Please feel free to reach out for questions, thoughts, or help :)
src/main.rs
Outdated
let editor = env::var("EDITOR").context("env `EDITOR` not set").unwrap(); | ||
let _ = std::process::Command::new(editor) |
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.
Right now, this does not work if people set EDITOR to something that includes arguments, for example EDITOR="nvim --clean" tldr --edit-page foo
. I checked a couple of programs for how they handle this. Both git config --edit
and sudoedit
just spawn nvim without arguments, omitting the --clean
. I suppose that having arguments in EDITOR is not a common thing then.
I think that crashing is better than omitting the arguments, so the current handling of EDITOR is fine. However, we should handle and print errors returned here.
Additionally, we should think about adding some documentation for this behavior, but let's postpone this until the code is ready.
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.
we can use shlex to parse
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.
Nah, as I said, the current behavior is probably exactly what we want to do. As long as the behavior is documented, I think we are good.
You could add a section at the end of docs/src/usage_custom_pages.md
to highlight the feature and we can phrase it so that the behavior is clear
6e0b71a
to
a811d68
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.
Tests look good and the flags seem to work, only some code style things left :)
c0bb691
to
4c25e7c
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.
I left some more comments on the previous discussions, please let me know what you think :)
023d886
to
af896f1
Compare
@lengyijun Can you address #388 (comment) ? We definitely want to have the test I described, and I think we will see that |
96fb67e
to
0bdc600
Compare
@lengyijun you marked #388 (comment) as resolved now, but the most crucial test I brought up is still missing: when we run tealdeer a second time, we should not get an error because of trying to create the directory. In general, I am a bit unsure on when I should take a look at the PR, please write a short comment or re-request my review on Github when you are ready :) |
ab8f04b
to
8c4b0cd
Compare
Fix tealdeer-rs#383 Co-authored-by: Niklas Mohrin <[email protected]>
Review requested |
Fix #383