告别 “修复拼写错误” 的提交...!

这个命令行工具可以检查拼写并显示建议的更正。

安装

二进制文件

我们可以从这里下载二进制文件。

Makefile

$ git clone git@github.com:ezura/spell-checker-for-swift.git
$ cd spell-checker-for-swift
$ make

Mint

$ mint install ezura/spell-checker-for-swift@5.3.0

用法

在 Xcode 中使用

设置

在与 xcodeproj 文件相同的目录中运行 typokana init

添加运行脚本

要在 Xcode 上显示警告,请将脚本添加到 “Run Script Phase”。

if which typokana >/dev/null; then
  typokana --diff-only
else
  echo "`typokana` is not installed."
fi

此设置仅在已更改的 swift 文件(通过 git diff 获取)中搜索拼写错误。

如果要选择目标目录,请添加目录路径。

if which typokana >/dev/null; then
  typokana /Sources
else
  echo "`typokana` is not installed."
fi

命令

typokana init

准备一个拼写检查器忽略的单词列表。
typokana init 在当前目录中创建 “.typokana_ignore”。

typokana

在所有 swift 文件中搜索拼写错误。
当此命令在 “Run Script” 中运行时,在 Xcode 上显示拼写错误的警告。

typokana -diff

推荐使用此命令。
仅在已更改的 swift 文件(通过 git diff 获取)中搜索拼写错误。

typokana --language

更改用于拼写检查的语言,例如 “en_US”(默认为使用系统语言)。 (typokana --language en_US)

typokana --help

(typokana --help)

OVERVIEW: Spell check

USAGE: typokana [options] argument

OPTIONS:
  --diff-only, -diff   Check only files listed by `git diff --name-only`
  --language, -l       The language to use for spell checking, e.g. "en_US" (defaults to using the system language).
  --help               Display available options

POSITIONAL ARGUMENTS:
  path | init          Path to target file | set up typokana

如何忽略单词

  1. 创建名为 “.typokana_ignore” 的文件
  2. 用换行符写入要忽略的单词

例如,如果您不想显示关于 “typokana”、“json” 和 “yuka” 的警告,请在 “.typokana_ignore” 中写入以下文本。

typokana
json
yuka