converted into multifile for ease

This commit is contained in:
Arctic 2025-03-07 04:08:40 -06:00
parent bfdcf11212
commit 2a7cb7dcb7
9 changed files with 148 additions and 176 deletions

View file

@ -1,24 +1,10 @@
# ssh_manager/add_host.py
import os
import subprocess
from .utils import print_error, print_warning, print_info
class Colors:
GREEN = "\033[0;32m"
RED = "\033[0;31m"
YELLOW = "\033[1;33m"
CYAN = "\033[0;36m"
BOLD = "\033[1m"
RESET = "\033[0m"
def print_error(message):
print(f"{Colors.RED}{Colors.BOLD}[✖] {Colors.RESET}{message}")
def print_warning(message):
print(f"{Colors.YELLOW}{Colors.BOLD}[⚠] {Colors.RESET}{message}")
def print_info(message):
print(f"{Colors.GREEN}{Colors.BOLD}[✔] {Colors.RESET}{message}")
def add_host(CONF_DIR):
def add_host(conf_dir):
"""
Interactive prompt to create a new SSH host in ~/.ssh/conf/<label>/config.
Offers to generate a new SSH key pair (ed25519) quietly (-q),
@ -40,7 +26,7 @@ def add_host(CONF_DIR):
port = input("Enter SSH port (default: 22): ").strip() or "22"
# Create subdirectory: ~/.ssh/conf/<label>
host_dir = os.path.join(CONF_DIR, host_label)
host_dir = os.path.join(conf_dir, host_label)
if os.path.exists(host_dir):
print_warning(f"Directory {host_dir} already exists; continuing anyway.")
else: