-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeclaude.py
More file actions
70 lines (58 loc) · 1.85 KB
/
declaude.py
File metadata and controls
70 lines (58 loc) · 1.85 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
# CLI entry point for declaude. Parses command-line arguments and invokes
# the export pipeline to convert Claude conversation JSON exports into
# styled, browsable HTML files with a navigable index page.
import argparse
import sys
from pathlib import Path
from zoneinfo import ZoneInfo
from exporter import export_conversations
def build_parser() -> argparse.ArgumentParser:
"""Build and return the argument parser for declaude.
Returns:
Configured ArgumentParser instance.
"""
parser = argparse.ArgumentParser(
prog="declaude",
description="Convert Claude conversation exports to styled, browsable HTML.",
)
parser.add_argument(
"input",
type=Path,
help="Path to conversations.json (Claude export file)",
)
parser.add_argument(
"-o", "--output",
type=Path,
default=Path("output"),
help="Output directory for HTML files (default: output)",
)
parser.add_argument(
"--utc",
action="store_true",
help="Use UTC timezone instead of US/Eastern",
)
parser.add_argument(
"-s", "--source",
type=str,
default="",
help="Source filename to display in index header",
)
return parser
def main() -> None:
"""Parse arguments and run the export pipeline."""
parser = build_parser()
args = parser.parse_args()
if not args.input.exists():
print(f"Error: Input file not found: {args.input}", file=sys.stderr)
sys.exit(1)
tz = ZoneInfo("UTC") if args.utc else None
count = export_conversations(
json_path=args.input,
output_dir=args.output,
tz=tz,
source_file=args.source or args.input.name,
)
print(f"Exported {count} conversations to {args.output}/")
print(f"open {args.output}/index.html")
if __name__ == "__main__":
main()