Adding cli

This commit is contained in:
2026-07-14 20:49:26 +02:00
parent 1fcd511f77
commit d5dc3c5e33
2 changed files with 320 additions and 85 deletions
+26 -85
View File
@@ -57,10 +57,12 @@ Examples:
gnommo -p video1 description Generate YouTube description file
gnommo -p video1 transcribe Narration file for timing of slides
gnommo -p video1 transcribe --final Transcribe outputted file and generate SRT for YouTube
gnommo -p video1 archive Sync project to external cache storage
gnommo -p video1 archive --dry-run Preview what would be synced
gnommo -p video1 up Upload project files to remote server
gnommo -p video1 down Download project files from remote server
gnommo -p video1 archive Copy project to connected external drive
gnommo -p video1 load Copy project from external drive to local
gnommo -p video1 commit -m "msg" Record a commit to commits.log (required before up)
gnommo -p video1 up Push manifest files to rendering server
gnommo -p video1 up --dry-run Preview which files would be pushed
gnommo -p video1 down Pull files from rendering server to local
gnommo -p video1 extract-audio --combined Extract audio from narration_combined.mov
gnommo -p video1 extract-audio --combined --channel left Extract left channel only
gnommo -p video1 extract-audio --segment seg01 Extract from a specific segment
@@ -100,6 +102,7 @@ Examples:
"description",
"archive",
"load",
"commit",
"up",
"down",
"extract-audio",
@@ -226,6 +229,13 @@ Examples:
dest="alpha_quality",
help="For transcode --processed: HEVC alpha quality 0.0-1.0 (default: 0.75; lower=smaller file)",
)
parser.add_argument(
"-m",
"--message",
type=str,
default=None,
help="For commit: commit message",
)
parser.add_argument(
"--search",
type=str,
@@ -322,10 +332,18 @@ Examples:
return cmd_archive(project_path, args.verbose, args.dry_run)
elif action == "load":
return cmd_load(project_path, args.verbose, args.dry_run)
elif action == "commit":
from .transfer import cmd_commit
if not args.message:
print("Error: -m 'message' is required for commit.")
return 1
return cmd_commit(project_path, args.message)
elif action == "up":
return cmd_sync(project_path, args.verbose, args.dry_run, download=False)
from .transfer import cmd_up
return cmd_up(project_path, args.verbose, args.dry_run)
elif action == "down":
return cmd_sync(project_path, args.verbose, args.dry_run, download=True)
from .transfer import cmd_down
return cmd_down(project_path, args.verbose, args.dry_run)
elif action == "extract-audio":
return cmd_extract_audio(
project_path, args.verbose, args.segment, args.channel, args.combined
@@ -4407,7 +4425,8 @@ def cmd_all(
return result
print("\n>>> Step 8/8: Upload\n")
return cmd_sync(project_path, verbose, dry_run, download=False)
from .transfer import cmd_up
return cmd_up(project_path, verbose, dry_run)
# =============================================================================
@@ -4710,84 +4729,6 @@ def cmd_load(project_path: Path, verbose: bool, dry_run: bool) -> int:
return 0
def cmd_sync(project_path: Path, verbose: bool, dry_run: bool, download: bool) -> int:
"""Sync project files to/from the remote server via rsync over SSH."""
from .cache import load_server_config
server = load_server_config()
if server is None:
print("Error: Server not configured. Add to ~/.gnommo.conf:")
print(" [server]")
print(" host = 76.13.144.52")
print(" user = root")
print(" path = /gnommo/project")
return 1
direction = "Downloading from" if download else "Uploading to"
print(f"{direction} server: {project_path.name}")
remote = f"{server['user']}@{server['host']}:{server['path']}/{project_path.name}/"
local = f"{project_path}/"
if download:
src, dest = remote, local
else:
src, dest = local, remote
print(f" Source: {src}")
print(f" Destination: {dest}")
# Ensure destination directory exists
if not dry_run:
if download:
project_path.mkdir(parents=True, exist_ok=True)
else:
remote_dir = f"{server['path']}/{project_path.name}"
ssh_cmd = [
"ssh",
"-p",
server["port"],
f"{server['user']}@{server['host']}",
f"mkdir -p {remote_dir}",
]
if verbose:
print(f" Creating remote dir: {remote_dir}")
result = subprocess.run(ssh_cmd)
if result.returncode != 0:
print(f"Error: could not create remote directory {remote_dir}")
return 1
rsync_cmd = [
"rsync",
"-av",
"--progress",
"-e",
f"ssh -p {server['port']}",
*[f"--exclude={p}" for p in _RSYNC_EXCLUDES],
# On upload: delete server-side files that no longer exist locally so
# the remote stays an exact mirror of the local project.
*(["--delete"] if not download else []),
src,
dest,
]
if dry_run:
rsync_cmd.insert(1, "--dry-run")
print("\n [DRY RUN] Would execute:")
print(f" {' '.join(rsync_cmd)}")
else:
print("\n Syncing files...")
if verbose:
print(f" Command: {' '.join(rsync_cmd)}")
result = subprocess.run(rsync_cmd)
if result.returncode != 0:
print(f"Error: rsync failed with code {result.returncode}")
return 1
print("\nDone.")
return 0
# =============================================================================