claude-session-sync-cli 0.1.2__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.1.3] - 2026-11-11
8
+
9
+ ### Added
10
+ - `--lang en|zh` to pick the output language for a single run; it overrides `CLAUDE_SESSION_SYNC_LANG` and the locale.
11
+ - The English `--help` now shows a one-line hint in Chinese on how to switch, and the Chinese `--help` shows the English equivalent.
12
+
7
13
  ## [0.1.2] - 2026-11-11
8
14
 
9
15
  ### Fixed
@@ -26,7 +32,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
26
32
  - `--version` and `--help` with examples.
27
33
  - English and Chinese output, chosen from the locale; override with `CLAUDE_SESSION_SYNC_LANG=en|zh`.
28
34
 
29
- [Unreleased]: https://github.com/xushenjie/claude-session-sync/compare/v0.1.2...HEAD
35
+ [Unreleased]: https://github.com/xushenjie/claude-session-sync/compare/v0.1.3...HEAD
36
+ [0.1.3]: https://github.com/xushenjie/claude-session-sync/compare/v0.1.2...v0.1.3
30
37
  [0.1.2]: https://github.com/xushenjie/claude-session-sync/compare/v0.1.1...v0.1.2
31
38
  [0.1.1]: https://github.com/xushenjie/claude-session-sync/compare/v0.1.0...v0.1.1
32
39
  [0.1.0]: https://github.com/xushenjie/claude-session-sync/releases/tag/v0.1.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: claude-session-sync-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Sync local Claude Code CLI sessions into the Claude desktop app sidebar (unofficial).
5
5
  Project-URL: Homepage, https://github.com/xushenjie/claude-session-sync
6
6
  Project-URL: Issues, https://github.com/xushenjie/claude-session-sync/issues
@@ -126,7 +126,7 @@ claude-session-sync --undo
126
126
 
127
127
  > If it says the desktop app is running, the app is still alive in the menu bar or system tray and **nothing was written**. Quit it fully and run again.
128
128
 
129
- Output is in English, or in Chinese when your locale (`LC_ALL` / `LC_MESSAGES` / `LANG`, or the Windows display language) is Chinese. Set `CLAUDE_SESSION_SYNC_LANG=en` or `zh` to override.
129
+ Output is in English, or in Chinese when your locale (`LC_ALL` / `LC_MESSAGES` / `LANG`, or the Windows display language) is Chinese. Pass `--lang en` or `--lang zh` for a single run, or set `CLAUDE_SESSION_SYNC_LANG=en` or `zh` in your shell profile to change it for good without touching your locale.
130
130
 
131
131
  ---
132
132
 
@@ -178,6 +178,7 @@ claude-session-sync --purge-archived --apply # do it
178
178
  |---|---|
179
179
  | `-h`, `--help` | Show help, examples, and caveats |
180
180
  | `-V`, `--version` | Show the version |
181
+ | `--lang en\|zh` | Output language; overrides `CLAUDE_SESSION_SYNC_LANG` and the locale |
181
182
  | (no options) | Preview mode |
182
183
  | `--apply` | Actually write |
183
184
  | `--undo` | Undo the most recent write or deletion |
@@ -97,7 +97,7 @@ claude-session-sync --undo
97
97
 
98
98
  > If it says the desktop app is running, the app is still alive in the menu bar or system tray and **nothing was written**. Quit it fully and run again.
99
99
 
100
- Output is in English, or in Chinese when your locale (`LC_ALL` / `LC_MESSAGES` / `LANG`, or the Windows display language) is Chinese. Set `CLAUDE_SESSION_SYNC_LANG=en` or `zh` to override.
100
+ Output is in English, or in Chinese when your locale (`LC_ALL` / `LC_MESSAGES` / `LANG`, or the Windows display language) is Chinese. Pass `--lang en` or `--lang zh` for a single run, or set `CLAUDE_SESSION_SYNC_LANG=en` or `zh` in your shell profile to change it for good without touching your locale.
101
101
 
102
102
  ---
103
103
 
@@ -149,6 +149,7 @@ claude-session-sync --purge-archived --apply # do it
149
149
  |---|---|
150
150
  | `-h`, `--help` | Show help, examples, and caveats |
151
151
  | `-V`, `--version` | Show the version |
152
+ | `--lang en\|zh` | Output language; overrides `CLAUDE_SESSION_SYNC_LANG` and the locale |
152
153
  | (no options) | Preview mode |
153
154
  | `--apply` | Actually write |
154
155
  | `--undo` | Undo the most recent write or deletion |
@@ -97,7 +97,7 @@ claude-session-sync --undo
97
97
 
98
98
  > 如果提示"检测到桌面端正在运行",说明桌面端还挂在菜单栏或托盘里,**这次什么都没有写入**。彻底退出后重新运行即可。
99
99
 
100
- 系统语言(`LC_ALL`、`LC_MESSAGES`、`LANG`,或 Windows 的显示语言)是中文时输出中文,否则输出英文。可以用 `CLAUDE_SESSION_SYNC_LANG=zh` 或 `en` 强制指定。
100
+ 系统语言(`LC_ALL`、`LC_MESSAGES`、`LANG`,或 Windows 的显示语言)是中文时输出中文,否则输出英文。临时切换加 `--lang zh` 或 `--lang en`;想长期使用中文,又不想改系统语言,在 shell 配置文件(如 `~/.zshrc`)里加上 `export CLAUDE_SESSION_SYNC_LANG=zh`。
101
101
 
102
102
  ---
103
103
 
@@ -149,6 +149,7 @@ claude-session-sync --purge-archived --apply # 执行
149
149
  |---|---|
150
150
  | `-h`, `--help` | 显示帮助、示例和注意事项 |
151
151
  | `-V`, `--version` | 显示版本号 |
152
+ | `--lang en\|zh` | 输出语言,优先于 `CLAUDE_SESSION_SYNC_LANG` 和系统语言 |
152
153
  | (不加参数) | 预览模式 |
153
154
  | `--apply` | 实际写入 |
154
155
  | `--undo` | 撤销最近一次写入或删除 |
@@ -40,7 +40,7 @@ import time
40
40
  import uuid
41
41
  from pathlib import Path, PurePosixPath, PureWindowsPath
42
42
 
43
- __version__ = "0.1.2"
43
+ __version__ = "0.1.3"
44
44
 
45
45
  HOME = Path.home()
46
46
  JOURNAL_DIR = HOME / ".claude-desktop-sync"
@@ -581,17 +581,32 @@ def purge_archived(indexes, archived_ids, projects, apply, trash, excluded=(), p
581
581
  # ---------------------------------------------------------------- 主流程
582
582
 
583
583
 
584
+ def apply_lang_flag(argv):
585
+ """在构建帮助文本之前先读取 --lang,让 --help 和后续输出都使用指定语言。
586
+ 非法取值交给正式的解析器报错。"""
587
+ global _LANG_ZH
588
+ pre = argparse.ArgumentParser(add_help=False)
589
+ pre.add_argument("--lang")
590
+ known, _ = pre.parse_known_args(argv)
591
+ if known.lang in ("en", "zh"):
592
+ _LANG_ZH = known.lang == "zh"
593
+
594
+
584
595
  def main(argv=None):
585
596
  use_safe_stdio()
597
+ apply_lang_flag(argv)
586
598
  ap = argparse.ArgumentParser(
587
599
  prog="claude-session-sync",
588
600
  formatter_class=argparse.RawDescriptionHelpFormatter,
589
601
  description=t(
590
602
  "Sync local Claude Code CLI sessions into the Claude desktop app's Code sidebar (multi-account).\n"
591
603
  "Archived sessions and sessions deleted in the desktop app are skipped. "
592
- "Previews by default; pass --apply to write.",
604
+ "Previews by default; pass --apply to write.\n"
605
+ # 这一行固定用中文:给终端设成英文的中文用户看
606
+ "中文输出:加 --lang zh,或设置环境变量 CLAUDE_SESSION_SYNC_LANG=zh",
593
607
  "把本地 Claude Code CLI 会话同步到 Claude 桌面端 Code 标签页的侧边栏(支持多账号)。\n"
594
- "自动排除已归档、桌面端已删除的会话。默认只预览,加 --apply 才写入。",
608
+ "自动排除已归档、桌面端已删除的会话。默认只预览,加 --apply 才写入。\n"
609
+ "English output: pass --lang en, or set CLAUDE_SESSION_SYNC_LANG=en",
595
610
  ),
596
611
  epilog=t(
597
612
  """\
@@ -612,7 +627,7 @@ Notes:
612
627
  * Quit the desktop app completely before writing, and reopen it afterwards.
613
628
  * Journals and backups live in ~/.claude-desktop-sync/; --undo steps back one run at a time.
614
629
  * The desktop index format is undocumented and may break with desktop updates.
615
- * Output language follows LANG; set CLAUDE_SESSION_SYNC_LANG=en or zh to override.
630
+ * Output language: --lang, then CLAUDE_SESSION_SYNC_LANG, then LC_ALL / LC_MESSAGES / LANG.
616
631
  """,
617
632
  """\
618
633
  常用流程:
@@ -632,11 +647,19 @@ Notes:
632
647
  * 写入前请彻底退出桌面端(菜单栏 ⌘Q),写完重新打开。
633
648
  * 日志与备份在 ~/.claude-desktop-sync/,--undo 按时间倒序逐次撤销。
634
649
  * 桌面端索引格式无官方文档,桌面端更新后可能失效。
635
- * 输出语言跟随 LANG,可用 CLAUDE_SESSION_SYNC_LANG=en 或 zh 强制指定。
650
+ * 输出语言:依次看 --lang、CLAUDE_SESSION_SYNC_LANG、LC_ALL / LC_MESSAGES / LANG。
636
651
  """,
637
652
  ),
638
653
  )
639
654
  ap.add_argument("-V", "--version", action="version", version=f"%(prog)s {__version__}")
655
+ ap.add_argument(
656
+ "--lang",
657
+ choices=["en", "zh"],
658
+ help=t(
659
+ "output language (default: from CLAUDE_SESSION_SYNC_LANG or the locale)",
660
+ "输出语言(默认:按 CLAUDE_SESSION_SYNC_LANG 或系统语言)",
661
+ ),
662
+ )
640
663
  ap.add_argument(
641
664
  "--apply", action="store_true", help=t("actually write (default: preview only)", "实际写入(默认只预览)")
642
665
  )
@@ -411,3 +411,36 @@ def test_include_recent_does_not_affect_purge(env):
411
411
  jsonl = env.add_cli_session("busy", mtime=time.time())
412
412
  env.run("--purge-archived", "--apply", "--include-recent")
413
413
  assert arch.exists() and jsonl.exists()
414
+
415
+
416
+ # ---------------------------------------------------------------- --lang
417
+
418
+
419
+ def test_lang_flag_switches_help_to_chinese(monkeypatch, capsys):
420
+ monkeypatch.setenv("CLAUDE_SESSION_SYNC_LANG", "en") # --lang 优先于环境变量
421
+ with pytest.raises(SystemExit):
422
+ cli.main(["--lang", "zh", "--help"])
423
+ out = capsys.readouterr().out
424
+ assert "实际写入" in out and "English output: pass --lang en" in out
425
+
426
+
427
+ def test_english_help_shows_chinese_hint(capsys):
428
+ with pytest.raises(SystemExit):
429
+ cli.main(["--help"])
430
+ out = capsys.readouterr().out
431
+ assert "actually write" in out
432
+ assert "中文输出:加 --lang zh" in out
433
+
434
+
435
+ def test_lang_flag_switches_run_output(env, capsys):
436
+ env.add_index("existing")
437
+ env.add_cli_session("new-1")
438
+ env.run("--lang=zh")
439
+ assert "预览模式" in capsys.readouterr().out
440
+
441
+
442
+ def test_invalid_lang_is_rejected(capsys):
443
+ with pytest.raises(SystemExit) as e:
444
+ cli.main(["--lang", "fr"])
445
+ assert e.value.code == 2
446
+ assert "invalid choice" in capsys.readouterr().err