From 223ebbdea3f228c19056aa50b6c41ac9ee057c9f Mon Sep 17 00:00:00 2001 From: Sam Balco Date: Tue, 20 Aug 2024 12:00:05 +0200 Subject: [PATCH] Shoerten hashes in kup list when terminal is less than 80 characters wide --- src/kup/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kup/__main__.py b/src/kup/__main__.py index b65d805..1defcca 100644 --- a/src/kup/__main__.py +++ b/src/kup/__main__.py @@ -1,6 +1,7 @@ import configparser import json import os +import shutil import subprocess import sys import textwrap @@ -55,6 +56,8 @@ KUP_DIR = os.path.split(os.path.abspath(__file__))[0] # i.e. /path/to/dir/ VERBOSE = False +TERMINAL_WIDTH, _ = shutil.get_terminal_size((80, 20)) + available_packages: list[GithubPackage] = [ GithubPackage('runtimeverification', 'kup', PackageName('kup')), GithubPackage('runtimeverification', 'k', PackageName('k')), @@ -376,7 +379,7 @@ def list_package( table_data = [['Package name (alias)', 'Installed version', 'Status'],] + [ [ str(PackageName(alias, p.package_name.ext).pretty_name), - f'{p.commit}{" (" + p.tag + ")" if p.tag else ""}' + f'{p.commit[:7] if TERMINAL_WIDTH < 80 else p.commit}{" (" + p.tag + ")" if p.tag else ""}' if type(p) == ConcretePackage else '\033[3mlocal checkout\033[0m' if type(p) == LocalPackage