-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeepsync_bootstrap.py
More file actions
48 lines (39 loc) · 1.36 KB
/
Copy pathkeepsync_bootstrap.py
File metadata and controls
48 lines (39 loc) · 1.36 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
"""Command-line bootstrap helpers for KeepSyncNotes."""
from typing import Callable, Sequence
TOKEN_FLAGS = {"--get-token", "-t", "--token"}
HELP_FLAGS = {"--help", "-h"}
def print_help(app_name: str, app_version: str, output: Callable[[str], None] = print) -> None:
output(f"{app_name} v{app_version}")
output("")
output("Usage: python keep_sync_notes.py [OPTIONS]")
output("")
output("Options:")
output(" --get-token, -t Generate a Google Master Token for Keep sync")
output(" --help, -h Show this help message")
output("")
output("Run without arguments to start the application.")
def run_bootstrap(
argv: Sequence[str],
app_factory: Callable[[], object],
token_cli: Callable[[], object],
app_name: str,
app_version: str,
set_appearance_mode: Callable[[str], None],
set_default_color_theme: Callable[[str], None],
output: Callable[[str], None] = print,
) -> int:
args = list(argv or [])
if len(args) > 1:
option = args[1]
if option in TOKEN_FLAGS:
token_cli()
return 0
if option in HELP_FLAGS:
print_help(app_name, app_version, output)
return 0
set_appearance_mode("dark")
set_default_color_theme("blue")
app = app_factory()
app.protocol("WM_DELETE_WINDOW", app.on_closing)
app.mainloop()
return 0