Use click.echo to output text

This commit is contained in:
Ivan Habunek 2023-12-04 18:45:40 +01:00
parent 452b98d2ad
commit eaaa14cfc2
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
2 changed files with 8 additions and 10 deletions

View File

@ -7,7 +7,6 @@ from typing import Optional
from toot import User, App, get_config_dir from toot import User, App, get_config_dir
from toot.exceptions import ConsoleError from toot.exceptions import ConsoleError
from toot.output import print_out
TOOT_CONFIG_FILE_NAME = "config.json" TOOT_CONFIG_FILE_NAME = "config.json"
@ -30,8 +29,6 @@ def make_config(path):
"active_user": None, "active_user": None,
} }
print_out("Creating config file at <blue>{}</blue>".format(path))
# Ensure dir exists # Ensure dir exists
os.makedirs(dirname(path), exist_ok=True) os.makedirs(dirname(path), exist_ok=True)

View File

@ -9,6 +9,8 @@ import warnings
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from typing import Dict from typing import Dict
import click
from toot.exceptions import ConsoleError from toot.exceptions import ConsoleError
from urllib.parse import urlparse, urlencode, quote, unquote from urllib.parse import urlparse, urlencode, quote, unquote
@ -148,14 +150,13 @@ def _tmp_status_path() -> str:
return f"{tmp_dir}/.status.toot" return f"{tmp_dir}/.status.toot"
def _use_existing_tmp_file(tmp_path) -> bool: def _use_existing_tmp_file(tmp_path: str) -> bool:
from toot.output import print_out
if os.path.exists(tmp_path): if os.path.exists(tmp_path):
print_out(f"<cyan>Found a draft status at: {tmp_path}</cyan>") click.echo(f"Found draft status at: {tmp_path}")
print_out("<cyan>[O]pen (default) or [D]elete?</cyan> ", end="")
char = read_char(["o", "d"], "o") choice = click.Choice(["O", "D"], case_sensitive=False)
return char == "o" char = click.prompt("Open or Delete?", type=choice, default="O")
return char == "O"
return False return False