Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Z4nzu
GitHub Repository: Z4nzu/hackingtool
Path: blob/master/constants.py
2370 views
1
from pathlib import Path
2
import platform
3
import shutil as _shutil
4
5
# ── Repository ────────────────────────────────────────────────────────────────
6
REPO_OWNER = "Z4nzu"
7
REPO_NAME = "hackingtool"
8
REPO_URL = f"https://github.com/{REPO_OWNER}/{REPO_NAME}.git"
9
REPO_WEB_URL = f"https://github.com/{REPO_OWNER}/{REPO_NAME}"
10
11
# ── Versioning ────────────────────────────────────────────────────────────────
12
VERSION = "2.0.0"
13
VERSION_DISPLAY = f"v{VERSION}"
14
15
# ── Python requirement ────────────────────────────────────────────────────────
16
MIN_PYTHON = (3, 10)
17
18
# ── User-scoped paths (cross-platform, always computed at runtime) ─────────────
19
# NEVER hardcode /home/username — use Path.home() so it works for any user,
20
# including root (/root), regular users (/home/alice), macOS (/Users/alice).
21
USER_CONFIG_DIR = Path.home() / f".{REPO_NAME}"
22
USER_TOOLS_DIR = USER_CONFIG_DIR / "tools"
23
USER_CONFIG_FILE = USER_CONFIG_DIR / "config.json"
24
USER_LOG_FILE = USER_CONFIG_DIR / f"{REPO_NAME}.log"
25
26
# ── System install paths (set per OS) ─────────────────────────────────────────
27
_system = platform.system()
28
29
if _system == "Darwin":
30
# macOS — Homebrew convention
31
APP_INSTALL_DIR = Path("/usr/local/share") / REPO_NAME
32
APP_BIN_PATH = Path("/usr/local/bin") / REPO_NAME
33
elif _system == "Linux":
34
APP_INSTALL_DIR = Path("/usr/share") / REPO_NAME
35
APP_BIN_PATH = Path("/usr/bin") / REPO_NAME
36
else:
37
# Fallback (Windows, FreeBSD, etc.)
38
APP_INSTALL_DIR = USER_CONFIG_DIR / "app"
39
APP_BIN_PATH = USER_CONFIG_DIR / "bin" / REPO_NAME
40
41
# ── UI theme ──────────────────────────────────────────────────────────────────
42
THEME_PRIMARY = "bold magenta"
43
THEME_BORDER = "bright_magenta"
44
THEME_SUCCESS = "bold green"
45
THEME_ERROR = "bold red"
46
THEME_WARNING = "bold yellow"
47
THEME_DIM = "dim white"
48
THEME_ARCHIVED = "dim yellow"
49
THEME_URL = "underline bright_blue"
50
THEME_ACCENT = "bold cyan"
51
52
# ── Default config values ──────────────────────────────────────────────────────
53
DEFAULT_CONFIG: dict = {
54
"tools_dir": str(USER_TOOLS_DIR),
55
"version": VERSION,
56
"theme": "magenta",
57
"show_archived": False,
58
"sudo_binary": "sudo",
59
"go_bin_dir": str(Path.home() / "go" / "bin"),
60
"gem_bin_dir": str(Path.home() / ".gem" / "ruby"),
61
}
62
63
# ── Privilege escalation ───────────────────────────────────────────────────────
64
# Prefer doas if present (OpenBSD/some Linux setups), else sudo
65
PRIV_CMD = "doas" if _shutil.which("doas") else "sudo"
66