From 5e0ef35744c66e769f98251b231f863619c91496 Mon Sep 17 00:00:00 2001 From: ilyukhin Date: Tue, 16 Sep 2025 16:55:44 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D1=84=D0=BB=D0=B0=D0=B3=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dsync | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/dsync b/dsync index e77c21c..16749c7 100644 --- a/dsync +++ b/dsync @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +VERSION = "0.1.0" + import sys import json import subprocess @@ -404,23 +406,24 @@ def list_nodes(): def show_help(): help_text = """ -dsync.py - Directory Synchronization Tool +dsync - Directory Synchronization Tool Usage: - dsync.py init Initialize dsync in current directory - dsync.py add-node [node2...] Add one or more nodes - dsync.py del-node [node2...] Remove one or more nodes - dsync.py list-nodes List all configured nodes - dsync.py status Show sync status for all nodes - dsync.py sync Sync to all configured nodes - dsync.py help Show this help message + dsync init Initialize dsync in current directory + dsync add-node [node2...] Add one or more nodes + dsync del-node [node2...] Remove one or more nodes + dsync list-nodes List all configured nodes + dsync status Show sync status for all nodes + dsync sync Sync to all configured nodes + dsync help Show this help message + dsync version Print dsync version Examples: - dsync.py init - dsync.py add-node user@server1.com user@server2.com - dsync.py del-node user@server1.com - dsync.py status - dsync.py sync + dsync init + dsync add-node user@server1.com user@server2.com + dsync del-node user@server1.com + dsync status + dsync sync Notes: - Status command shows pending changes without syncing @@ -430,6 +433,11 @@ Notes: """ print(help_text) +def show_version(): + """Print dsync version.""" + print(f"dsync {VERSION}") + + if __name__ == "__main__": if len(sys.argv) < 2: show_help() @@ -439,24 +447,27 @@ if __name__ == "__main__": if cmd == "init": init() - elif cmd == "add-node": + elif cmd in ("-an", "--add-node", "add-node"): if len(sys.argv) < 3: print(colored("Usage: dsync.py add-node [node2...]", Colors.RED)) sys.exit(1) add_nodes(*sys.argv[2:]) - elif cmd == "del-node": + elif cmd in ("-dn", "--del-node", "del-node"): if len(sys.argv) < 3: print(colored("Usage: dsync.py del-node [node2...]", Colors.RED)) sys.exit(1) del_nodes(*sys.argv[2:]) - elif cmd == "list-nodes": + elif cmd in ("-ln", "--list-nodes", "list-nodes"): list_nodes() elif cmd == "status": status() elif cmd == "sync": sync() - elif cmd == "help": + elif cmd in ("-h", "--help", "help"): show_help() + elif cmd in ("-v", "--version", "version"): + show_version() + sys.exit(0) else: print(colored(f"Unknown command: {cmd}", Colors.RED)) show_help()