Files
path-juggler/path_juggler.py

100 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""
Path Juggler - Command Line Interface
Watches folders for rendered files and automatically organizes them
into structured folder hierarchies based on source material locations.
Usage:
python3 path_juggler.py [--dry-run] [--once] [-v]
For the GUI version, run:
python3 path_juggler_gui.py
"""
import argparse
import logging
import time
from path_juggler_core import PathJuggler, get_honey_volumes
# Setup logging for CLI
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
datefmt="%H:%M:%S"
)
logger = logging.getLogger(__name__)
def main():
parser = argparse.ArgumentParser(
description="Watch for rendered files and organize into structured folders"
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Show what would be done without actually moving files"
)
parser.add_argument(
"--once",
action="store_true",
help="Process existing files and exit (don't watch)"
)
parser.add_argument(
"--verbose", "-v",
action="store_true",
help="Enable verbose logging"
)
parser.add_argument(
"--gui",
action="store_true",
help="Launch the GUI version"
)
args = parser.parse_args()
# Launch GUI if requested
if args.gui:
from path_juggler_gui import main as gui_main
gui_main()
return
if args.verbose:
logging.getLogger().setLevel(logging.DEBUG)
if args.dry_run:
logger.info("DRY RUN MODE - no files will be moved")
# Create juggler instance
juggler = PathJuggler(dry_run=args.dry_run)
if args.once:
# Just process existing files and exit
juggler.setup_folders()
volumes = get_honey_volumes()
if volumes:
logger.info(f"Found HONEY volumes: {[v.name for v in volumes]}")
else:
logger.warning("No HONEY volumes currently mounted")
logger.info("Processing existing files...")
juggler.process_existing()
logger.info("Done")
return
# Start watching
juggler.start()
try:
while juggler.is_running():
time.sleep(1)
except KeyboardInterrupt:
logger.info("Interrupted")
finally:
juggler.stop()
if __name__ == "__main__":
main()