biox / pa

a simple password manager. encryption via age, written in portable posix shell
https://passwordass.org
Other
505 stars 21 forks source link

Piping passwords into `pa` #39

Closed mbauhardt closed 2 days ago

mbauhardt commented 3 weeks ago

why

For scripting purpose it would be helpful

  1. to be able to pipe content to pasmth like
$ echo 'hello world' | pa a Notes/my-secret-note
  1. an option to force to overwrite an already existing file
arcxio commented 3 weeks ago
  1. to be able to pipe content to pa

It's already possible, it's just more convoluted:

$ echo -e 'nhello world\nhello world' | pa a Notes/my-secret-notes
Generate a password? [y/N]: n
Enter a password: 
Enter a password (again): 
Saved 'Notes/my-secret-notes' to the store.

I guess we could detect if there is piped input and disable interactivity in that case so that your example works as intended - that does seem reasonable to me. Though that would break our menu scripts because they pipe 'y' so that password is generated. We can say it now generates a password if we pipe an empty string to account for this, but this may be a bit unintuitive. One more option that came to mind, which is also weird, is we leave the first y/n prompt for generation as is so that menu scripts work like they do now, but you don't have to double your password in input:

$ echo 'nhello world' | pa a Notes/my-secret-notes
  1. There won't be any options in pa. Can you explain what you'd like to achieve with it? You can just rm the password file before you add it again. If you want to do it with pa, you can do it like this (you can also pipe echo y or yes - whichever you prefer):
    $ printf y | pa d name
    Delete password 'name'? [y/N]: y
mbauhardt commented 3 weeks ago

Awesome, All your example snippets works fine. For my taste this is enough and solves all my issues/questions i have.

you can close this issue if you want. maybe adding this to the FAQ/readme would give an answer to other people if they want to programatically works with pa.

background: i access my google mails via oauth2 and save my tokens with pa. the refresh token is refreshed via cron job and i need a way to pipe this token to pa.

thx marko