-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprofilesync.py
More file actions
executable file
·110 lines (95 loc) · 3.22 KB
/
profilesync.py
File metadata and controls
executable file
·110 lines (95 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python3
# Copyright 2026 Duke
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
profilesync - Cross-platform slicer profile sync tool
Sync 3D printer slicer profiles (Bambu Studio, OrcaSlicer, etc.) via GitHub.
Supports macOS, Windows, and Linux.
"""
import argparse
import sys
import textwrap
from profilesync.commands import cmd_config, cmd_init, cmd_sync
def main(argv: list[str] | None = None) -> int:
"""Main CLI entry point."""
parser = argparse.ArgumentParser(
prog="profilesync",
description="Sync 3D slicer profiles (Bambu Studio, OrcaSlicer) via GitHub",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=textwrap.dedent("""\
Examples:
profilesync init # Interactive setup
profilesync init --remote git@github.com:user/repo.git
profilesync sync # Interactive sync
profilesync config # Show current config
""")
)
subparsers = parser.add_subparsers(
dest="command", help="Available commands")
# init command
init_parser = subparsers.add_parser(
"init",
help="Initialize configuration and clone remote repo"
)
init_parser.add_argument(
"--remote",
help="GitHub remote URL (SSH or HTTPS)"
)
init_parser.add_argument(
"--repo-dir",
help="Local clone directory (default: auto-detect from remote)"
)
init_parser.add_argument(
"--editor",
help="Editor command for conflict resolution (default: 'code --wait')"
)
# sync command
subparsers.add_parser(
"sync",
help="Sync profiles between local slicers and server"
)
# config command
subparsers.add_parser(
"config",
help="Show current configuration"
)
args = parser.parse_args(argv)
if not args.command:
parser.print_help()
return 2
try:
if args.command == "init":
return cmd_init(args)
elif args.command == "sync":
return cmd_sync(args)
elif args.command == "config":
return cmd_config(args)
else:
parser.print_help()
return 2
except FileNotFoundError as e:
print(f"Error: {e}")
print(f"\nRun 'profilesync init' first to set up configuration.")
return 1
except KeyboardInterrupt:
from profilesync.ui import info
print(info("\nAborted. No changes were made to remote or local files."))
return 130
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
return 1
if __name__ == "__main__":
sys.exit(main())