summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/src/meshbay_cli/commands/account.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-cli/src/meshbay_cli/commands/account.py')
-rw-r--r--packages/meshbay-cli/src/meshbay_cli/commands/account.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/meshbay-cli/src/meshbay_cli/commands/account.py b/packages/meshbay-cli/src/meshbay_cli/commands/account.py
index 4499f0b..1fbef13 100644
--- a/packages/meshbay-cli/src/meshbay_cli/commands/account.py
+++ b/packages/meshbay-cli/src/meshbay_cli/commands/account.py
@@ -35,7 +35,7 @@ from ..client.passphrase import passphrase_problem, solve_captcha
from ..client.rewrap import Carried, carry
from ..client.store import FILE_KEY_NOTICE, KEY_FILE
from ..errors import AUTH, NOT_FOUND, REFUSED, USAGE, CliError
-from ..output import confirm, err, safe, sentence
+from ..output import confirm, err, safe, sentence, terminal
from .context import Context
HELP = ("your account: show it, register, verify, change or reset the passphrase, "
@@ -102,7 +102,7 @@ async def run(ctx: Context) -> int:
def _ask(prompt: str, given: str | None, what: str) -> str:
if given:
return given.strip()
- if not sys.stdin.isatty():
+ if not terminal(sys.stdin):
raise CliError(USAGE, f"Name the {what}: there is no terminal to ask on.")
value = input(prompt).strip()
if not value:
@@ -121,7 +121,7 @@ def _read_first_line(path: str) -> str:
def _new_passphrase(given: str | None) -> str:
"""A new passphrase: `given`, else typed twice at a terminal; held to the floor."""
if given is None:
- if not sys.stdin.isatty():
+ if not terminal(sys.stdin):
raise NoPassphrase("A new passphrase is needed and there is no terminal to "
"ask on.")
given = getpass.getpass("New passphrase: ")
@@ -224,7 +224,7 @@ async def _register(ctx: Context) -> int:
"Keep it somewhere safe, apart from your passphrase. If you forget the "
"passphrase, it is what gives you your groups back.")
del raw
- if not sys.stdin.isatty() or ctx.args.json:
+ if not terminal(sys.stdin) or ctx.args.json:
err(f"A code was sent to {safe(email)}. Then: meshbay-cli account verify CODE "
f"--email {safe(email)}")
return 0
@@ -355,7 +355,7 @@ async def _reset(ctx: Context) -> int:
raise _hub_refusal(e, "No code sent") from e
err(f"If {safe(username)} and {safe(email)} are an account's, a code is on its "
"way there (valid one hour).")
- if not sys.stdin.isatty():
+ if not terminal(sys.stdin):
err(f"Then: meshbay-cli account reset -u {safe(username)} --code CODE")
return 0
code = _ask("The code: ", None, "code")
@@ -365,7 +365,7 @@ async def _reset(ctx: Context) -> int:
text = (sys.stdin.read() if a.recovery_key_file == "-"
else Path(a.recovery_key_file).read_text(encoding="utf-8"))
recovery = text.strip()
- elif sys.stdin.isatty():
+ elif terminal(sys.stdin):
recovery = input("Your recovery key (Enter if you have none): ").strip()
rkey = None
if recovery:
@@ -429,7 +429,7 @@ async def _email(ctx: Context, account: Account) -> int:
await account.call(account.hub.change_email, address, ak)
except HubError as e:
raise _hub_refusal(e, "Not changed") from e
- if ctx.args.json or not sys.stdin.isatty():
+ if ctx.args.json or not terminal(sys.stdin):
_say(ctx, {"email_verification_required": True, "email": address},
f"A code was sent to {safe(address)}. Then: meshbay-cli account email "
"--code CODE")