Skip to content
This repository was archived by the owner on Oct 16, 2021. It is now read-only.

Display find results in a tree like password-store does #2

Open
cole-h opened this issue Apr 27, 2020 · 2 comments
Open

Display find results in a tree like password-store does #2

cole-h opened this issue Apr 27, 2020 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@cole-h
Copy link
Owner

cole-h commented Apr 27, 2020

Last time I looked into this, I had a hard time implementing it on top of my current tree stuff used for passrs ls. Right now, I'm mostly satisfied with how passrs find looks and behaves (barring any bugs I've overlooked), but it would be nice if it were possible to draw a tree just like pass does when using pass find.

$ pass find beale
Search Terms: beale
└── Uncategorized
    └── Beale Diceware Wordlist
        └── attachments
            └── beale.wordlist.asc

vs

$ passrs find beale
Uncategorized/Beale Diceware Wordlist/attachments/beale.wordlist.asc
@cole-h cole-h added the help wanted Extra attention is needed label Apr 27, 2020
@colemickens
Copy link

Does it make sense to output different things based on if this command is being piped into something?

@cole-h
Copy link
Owner Author

cole-h commented Apr 27, 2020

pass doesn't make that distinction (pass find beale > test creates a text file that shows exactly what you see above, complete with ANSI codes), but I do in a few places. See, for example:

// if stdout is not a tty, it is being piped, so only
// print the first line
write!(io::stdout(), "{}", &password[0])?;

ETA: Basically, I think yes, it is useful to have a distinction where the output could be used by another program, e.g. passrs show Internet/amazon.com/testuser/awstoken | <some aws cli needing a token>. passrs show will, if it finds a tty, print Contents of Internet/amazon.com/testuser/awstoken followed by the actual contents on the next line(s), whereas piping it somewhere will print only the first line (since that is usually where people store their passwords/etc).

EDIT2: In situations where I believe a tty should be required (e.g. when user input is required, like passrs insert asd/fgh), I have a little helper function that I call that bails out when no tty is present:

util::ensure_stdout_is_tty()?;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants