pimterry/notes

Feature Request: notes cat command

arael opened this issue · 5 comments

arael commented

I think a useful command would be "notes cat [pattern]".
The command should output the content of the note and partial file names specified as pattern should be accepted too.
The pattern searching should be fuzzy.

I'd like to not reimplement matching, since notes find and notes grep already do that, and larger commands are less composable. I'd like something to be able to do this composably though. Something like:

notes find <pattern> | notes cat

There notes cat would be a command that takes one or more note names from stdin, and outputs their contents in turn.

Actually, you can nearly already do that with xargs cat (and it'd be nice not to reimplement that), except for the fact that find current returns paths relative to the notes directory, not absolute paths. I think this might tie into my current thinking about changing the behaviour of commands when they're being piped into something vs when they're displayed to a TTY directly. find could plausibly show humans nice convenient notes-relative paths, but send more useful absolute paths when being piped into other commands.

If you could run notes find <pattern> | xargs cat, would that work for you?

arael commented

I didn't consider the pipe. You are right. That solves the issue.

Wait wait wait, don't close this, it doesn't actually work yet!

You can't pipe into xargs cat because notes find produces relative URLs, and notes cat (the alternative example above) doesn't exist yet.

Sounds like xargs cat would solve your problem if it did though. Is that right?

If that works for you I'll reopen this and start looking into that.

arael commented

That would be one solution. Another solution would be a new command "show" which outputs the note content to the user.

You could use the "notes find" in the "notes show" though. That way you could still provide the fuzzy search to the "show" command.

But I understand you want to keep things UNIX way. I was just considering shorter and more convenient commands for users. Please let not my personal preference sway your ideas. It is just a suggestion.

I think the right solution to this is to make it possible to pipe to xargs cat, rather than reimplementing exactly that from scratch. I'm going to close this (again, sorry), and track the work to do that separately in #23. I'm aiming for that to let you run something like notes find <pattern> | xargs cat successfully though, so you should get this feature for free once that's completed.

Don't worry about it just being your personal preference - individual user feedback is what you need to build good software! Good idea, thanks for getting involved.