Open furudean opened 5 years ago
Hi @c-bandy, thanks for the feedback. Very happy this is useful to others.
This is a good point. I agree that a command line utility should be composable and behave predictably.
I use the mutating pasteboard heavily myself, so I'll take a look, and see how I could refactor this to accomodate both use cases.
@kirsis Maybe the --stdout
flag can have the behavior I describe, and we can move the current behavior to another flag, --show-token
(-S
/-s
)?
Hello, we used complex passwords, where OTP is part of password. I used before:
oathtool --totp -b ${OTP_TOKEN}
Your tool is great, cos it used Touch ID. Will be nice to have some behariour as oathtool
, without any interractive modes. Simple print token and exit.
fwiw
from collections import deque
import re
from subprocess import Popen, PIPE
def popen(cmd):
return Popen(cmd.split(' '), stdout=PIPE, stderr=PIPE, stdin=PIPE, bufsize=0)
def twofa(user, account):
resp = deque(maxlen=6)
with popen(f'twofa get --stdout {user}@{account}') as p:
while 1:
resp.append(p.stdout.read(1).decode())
code = ''.join(resp)
if re.match(r'[0-9]{6}', code):
return code
return None
Exactly the tool I was looking for and so glad I didn't have to write it myself! Thanks! Just wanted to add another vote to this issue. I need to include this in other automation scripts. Doesn't matter to me what flag is used or if one is used at all, but this behavior of printing one code and exiting is an absolute necessity.
Hi, first of all, this tool is fantastic and has made my life a lot easier - so thanks for that!
I think the
--stdout
flag would be more useful if its behavior was changed to only output a single auth token, and then exit. No bells and whistles of mutating your pasteboard. This would make automating with other tools more useful, and is also more standard since it's what the--stdout
flag usually does in a program.An example of where this is useful is with CLI tools that use MFA tokens. If you have MFA and you need to auth you can use command substitution to do this, eliminating the step of needing to paste the code.