finished the config
This commit is contained in:
19
publish_meetups/utils/__init__.py
Normal file
19
publish_meetups/utils/__init__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from pathlib import Path
|
||||
|
||||
import platformdirs
|
||||
|
||||
|
||||
PROGRAM_NAME: str = "publish-meetups"
|
||||
|
||||
|
||||
class Paths:
|
||||
CONFIG_PATH: Path = Path(platformdirs.user_config_path(appname=PROGRAM_NAME))
|
||||
|
||||
|
||||
Paths.CONFIG_PATH.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
|
||||
__all__ = ["prompt", "CONFIG_PATH", "PROGRAM_NAME", "errors"]
|
||||
|
||||
|
||||
4
publish_meetups/utils/error.py
Normal file
4
publish_meetups/utils/error.py
Normal file
@@ -0,0 +1,4 @@
|
||||
class InvalidCredential(Exception):
|
||||
def __init__(self, message):
|
||||
super().__init__(message)
|
||||
|
||||
21
publish_meetups/utils/prompt.py
Normal file
21
publish_meetups/utils/prompt.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import Optional
|
||||
|
||||
from getpass import getpass
|
||||
|
||||
|
||||
def for_string(msg: str, default: Optional[str] = None) -> str:
|
||||
def _real_prompt() -> str:
|
||||
nonlocal msg, default
|
||||
|
||||
if default is not None:
|
||||
return input(f"{msg} [{default}]: ").strip() or default
|
||||
|
||||
return input(msg + ': ').strip()
|
||||
|
||||
result = _real_prompt
|
||||
print("> " + result)
|
||||
return result
|
||||
|
||||
|
||||
def for_password(msg: str) -> str:
|
||||
return getpass.getpass(msg + ': ').strip()
|
||||
Reference in New Issue
Block a user