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

Add args: --edit-page and --edit-patch #388

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lengyijun
Copy link

Fix #383

@lengyijun lengyijun force-pushed the edit-page branch 4 times, most recently from c54276c to b540fc9 Compare November 2, 2024 08:39
Copy link
Collaborator

@niklasmohrin niklasmohrin left a 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/cli.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated
Comment on lines 333 to 334
let editor = env::var("EDITOR").context("env `EDITOR` not set").unwrap();
let _ = std::process::Command::new(editor)
Copy link
Collaborator

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.

src/main.rs Outdated Show resolved Hide resolved
@lengyijun lengyijun force-pushed the edit-page branch 4 times, most recently from c757300 to 6e0b71a Compare November 10, 2024 03:06
Fix tealdeer-rs#383

Co-authored-by: Niklas Mohrin <dev@niklasmohrin.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add flag to open editor
2 participants