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

edit: implement pazi edit #71

Merged
merged 11 commits into from
Aug 4, 2018
Merged

edit: implement pazi edit #71

merged 11 commits into from
Aug 4, 2018

Conversation

euank
Copy link
Owner

@euank euank commented Jun 7, 2018

Fixes #33

Note, this ends up doing significant work to expose the raw underlying frecency value to the user.
Unfortunately, that value is actually quite difficult to work with, but I think making a more human-editable version of it is something TBD independently and this is the most reasonable initial implementation.

This also does a decent chunk of work around escaping and editor-choosing, but so be it.

src/main.rs Outdated
@@ -186,6 +195,38 @@ fn _main() -> PaziResult {
}
}

if let Some(_) = flags.subcommand_matches("edit") {
let mut fclone = frecency.clone();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find an easy way to avoid this clone; feel free to try if you'd like.

I'm not too worried about performance in the pazi edit path, so I didn't try too hard.

@euank euank added this to the v0.0.3 milestone Jun 10, 2018
@euank euank force-pushed the tmp/wip/editx branch 2 times, most recently from 8a80df7 to 3a7dcda Compare July 2, 2018 02:45
Cargo.toml Outdated
@@ -26,3 +26,6 @@ log = "~0.3"
termion = "~1"
chan = "~0.1"
chan-signal = "~0.3"
tempfile = "3"
which = "2"
sh_escape = { path = "./pkg/sh_escape" }
Copy link

@iliana iliana Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You won't be able to publish the pazi crate to crates.io without specifying a version here, and also separately publishing sh_escape.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, darn. Thanks.

I guess I'll have to think of an okay name for it so I can publish it separately then.

euank added 8 commits July 13, 2018 14:25
Let the caller decide to normalize as an optional second step
This is helpful for 'pazi edit'
To be used shortly in the 'pazi edit' work
This implements a 'pazi edit' subcommand which may be used to edit the
pazi database in your $EDITOR of choice.
@euank
Copy link
Owner Author

euank commented Jul 13, 2018

I fixed the pkg / crates.io issue by splitting out that code into https://github.com/euank/snailquote. At this point, I think this should be pretty much good to go.

Copy link
Collaborator

@LinuxMercedes LinuxMercedes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

src/edit.rs Outdated
continue;
}

line = line.trim_right();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why not just trim()?
  2. If you move this above line 135, it handles the case of lines with just whitespace instead of erroring on them.

@euank
Copy link
Owner Author

euank commented Aug 4, 2018

@LinuxMercedes updated with the trim change, and I also shuffled around min/max per your out-of-band comment.

I moved it to take an iterator and lazily do stuff itself

@euank euank merged commit dcacfde into master Aug 4, 2018
@euank euank deleted the tmp/wip/editx branch August 4, 2018 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants