Skip to content

feat: unified convert --to CLI (textutil-compatible) - #28

Merged
kiki830621 merged 6 commits into
mainfrom
feat/convert-cli
Mar 15, 2026
Merged

kiki830621 merged 6 commits into
mainfrom
feat/convert-cli

Conversation

@kiki830621

Copy link
Copy Markdown
Member

Summary

  • Add macdoc convert --to <format> <file> as unified conversion entry point
  • Auto-detect input format from file extension
  • Route to correct converter package based on (input, target) pair
  • Old subcommands kept as aliases for backward compatibility

Routing table

Input ext --to Converter
.docx md WordConverter
.html/.htm md HTMLConverter
.md html MarkdownConverter
.srt html SRTConverter
.bib html BibToAPAHTMLFormatter
.bib md BibToAPAFormatter
.bib json BibToAPAJSONFormatter

Usage

macdoc convert --to md file.docx
macdoc convert --to html file.md
macdoc convert --to html file.srt
macdoc convert --to html file.bib --full
macdoc convert --to md file.bib
macdoc convert --to json file.bib
macdoc convert --to md file.html

Options

  • --output <path> — write to file instead of stdout
  • --stdout — force output to stdout
  • --hard-breaks — treat soft breaks as hard line breaks
  • --full — output full HTML document (for md→html and bib→html)
  • --style <style> — citation style (reserved for future use)
  • --model <model> — model for token counting (reserved for future use)

Design

Follows macOS textutil -convert pattern per .claude/rules/cli-textutil-compat.md

Closes #27

🤖 Generated with Claude Code

Implement textutil-compatible CLI pattern where all conversions go through
a single `convert` subcommand with --to flag for target format.
Input format auto-detected from file extension.
Old subcommands (word, html, md, srt, bib) kept for backward compatibility.

Routing table:
  .docx → md    (WordConverter)
  .html → md    (HTMLConverter)
  .md   → html  (MarkdownConverter)
  .srt  → html  (SRTConverter)
  .bib  → html  (BibToAPAHTMLFormatter)
  .bib  → md    (BibToAPAFormatter)
  .bib  → json  (BibToAPAJSONFormatter)

Closes #27
- Remove non-existent Markdown.self from subcommands
- Replace unused --style/--model with --css flag for bib CSS selection
- Fix resolveOutputPath docstring (--stdout wins, not --output)
- De-duplicate APACSS.web in convertBibToHTML
- Use ParsableCommand instead of AsyncParsableCommand (no async calls)
- Fix dependency: use remote doc-converter-swift v0.4.0 (CommonConverterSwift)
Establish that macdoc must prioritize macOS native frameworks
(PDFKit, Vision, CoreGraphics) over external tools. Includes
capability mapping table and new-converter checklist.
@kiki830621
kiki830621 merged commit 114fbca into main Mar 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: unify CLI to macdoc convert --to pattern (textutil-compatible)

1 participant