Evidlo / passhole

A secure hole for your passwords (KeePass CLI)
GNU General Public License v3.0
199 stars 19 forks source link

(FR) Implement various output formats #60

Open DegenComedian opened 1 year ago

DegenComedian commented 1 year ago

for using passhole in automation pipelines it would be benefical, if we could manage output formats on list subcommand. The "tree" structured output format is a bit of a pain to parse.

For example, we could have a --output-format <json, yam> which we could then pipe into yq or jq.

Evidlo commented 1 year ago

Sorry it took me long to get back to you.

Can you give a specific example of what you're looking for? At some point, just using the underlying pykeepass API and writing in Python is going to be less kludgy than handling it in shell scripts, especially if you're talking about trees.

>>> from passhole.passhole import open_database
>>> kp = open_database()
Enter database password (passhole): 
>>> kp.entries
[Entry: "collegeboard.org (evanwidloski)",
 Entry: "hackillinois.org (None)",
...

There is also the not very well-documented eval command, which does the first two lines for you

ph eval 'kp.entries'
realshovanshah commented 11 months ago

Hey! I'd also like to advocate for some form of output variation.

In particular, the default implementation, I believe, should handle most of the use cases for different output types. Some (more unix-like) examples would be: listing all entries in the root group, all entries in a particular group, listing all groups in the root group, etc — primarily as a single column list of entries as output.

And speaking of unix philosophy, the current tree output feels a bit secondary as the user can always use the said tree command to get this view; there's also the fact that list outputs tend to play well with the unix ecosystem in general — perhaps with jq and yq too — giving the user more flexibility (while maybe also making passhole's internal implementation more extensible). Anyway, the unsolicited feedback isn't to take away anything from this decent tool that you've created; as a recent user, this has been a very handy unix interface to KeePass (thanks!).

Finally, I had a doubt regarding this command you mention:

There is also the not very well-documented eval command, which does the first two lines for you

This command doesn't seem to be available to me in 1.10.0, could you confirm? Here's me running the command:

image
Evidlo commented 11 months ago

@realshovanshah I thought I had commited that feature already, but I've just pushed it now to master. Give it a try and let me know what you think.

See the manual for examples, as the interface has changed a little bit since I made that comment.

realshovanshah commented 10 months ago

Hey @Evidlo, 1.10.0 is still the most recent version.

Evidlo commented 10 months ago

Right, just wanted to get your feedback before making a release.

realshovanshah commented 10 months ago

I'm sorry, I'm using a package manager.