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

Feature Request: notes cat command #9

Closed
arael opened this issue Dec 2, 2016 · 5 comments
Closed

Feature Request: notes cat command #9

arael opened this issue Dec 2, 2016 · 5 comments

Comments

@arael
Copy link

arael commented Dec 2, 2016

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.

@pimterry
Copy link
Owner

pimterry commented Dec 2, 2016

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
Copy link
Author

arael commented Dec 2, 2016

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

@arael arael closed this as completed Dec 2, 2016
@pimterry
Copy link
Owner

pimterry commented Dec 2, 2016

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 arael reopened this Dec 2, 2016
@arael
Copy link
Author

arael commented Dec 2, 2016

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.

@pimterry
Copy link
Owner

pimterry commented Dec 6, 2016

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.

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

No branches or pull requests

2 participants