CLI: History supports multiple attrs from the same url now. Errors when executing the cli are formatted better

This commit is contained in:
Qubasa
2024-01-16 16:16:12 +01:00
parent de52a55228
commit 8da8889b5d
5 changed files with 68 additions and 31 deletions

View File

@@ -1,7 +1,21 @@
import os
from math import floor
from pathlib import Path
from typing import NamedTuple
def get_term_filler(name: str) -> int:
width, height = os.get_terminal_size()
filler = floor((width - len(name)) / 2)
return filler - 1
def text_heading(heading: str) -> str:
filler = get_term_filler(heading)
return f"{'=' * filler} {heading} {'=' * filler}"
class CmdOut(NamedTuple):
stdout: str
stderr: str
@@ -12,15 +26,16 @@ class CmdOut(NamedTuple):
def __str__(self) -> str:
return f"""
{text_heading(heading="Command")}
{self.command}
{text_heading(heading="Stderr")}
{self.stderr}
{text_heading(heading="Stdout")}
{self.stdout}
{text_heading(heading="Metadata")}
Message: {self.msg}
Working Directory: '{self.cwd}'
Return Code: {self.returncode}
=================== Command ===================
{self.command}
=================== STDERR ===================
{self.stderr}
=================== STDOUT ===================
{self.stdout}
"""