Skip to content

Commit

Permalink
Expand usage docs and fix obsolete reference to --language
Browse files Browse the repository at this point in the history
Fixes #712
  • Loading branch information
Wilfred committed May 13, 2024
1 parent 809f491 commit 5a250d6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 22 deletions.
44 changes: 31 additions & 13 deletions manual/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

### Diffing Files

```
$ difft sample_files/before.js sample_files/after.js
```bash
$ difft FIRST-FILE SECOND-FILE

# For example:
$ difft sample_files/simple_1.js sample_files/simple_2.js
```

### Diffing Directories

```
```bash
$ difft FIRST-DIRECTORY SECOND-DIRECTORY

# For example:
$ difft sample_files/dir_1/ sample_files/dir_2/
```

Expand All @@ -24,8 +30,11 @@ contain many unchanged files.

You can read a file from stdin by specifying `-` as the file path.

```
$ cat sample_files/before.js | difft - sample_files/after.js
```bash
$ difft - SECOND-FILE

# For example:
$ cat sample_files/simple_1.js | difft - sample_files/simple_2.js
```

### Files With Conflicts
Expand All @@ -36,23 +45,32 @@ If you have a file with `<<<<<<<` conflict markers, you can pass it as
a single argument to difftastic. Difftastic will construct the two
file states and diff those.

```
```bash
$ difft FILE-WITH-CONFLICTS

# For example:
$ difft sample_files/conflicts.el
```


## Language Detection

Difftastic guesses the language used based on the file extension, file
name, and the contents of the first lines.
name, and the contents of the first lines. To see the languages
available, and the associated file names, use the `--list-languages`
option.

```
$ difft --list-languages
```

You can override the language detection by passing the `--language`
option. Difftastic will treat input files as if they had that
extension, and ignore other language detection heuristics.
You can override language detection for specific file globs using the
`--override` option.

```bash
$ difft --override=GLOB:NAME FIRST-FILE SECOND-FILE

```
$ difft --language cpp before.c after.c
# For example, treating .h files as C rather than C++:
$ difft --override=*.h:c sample_files/preprocesor_1.h sample_files/preprocesor_2.h
```

## Options
Expand Down
29 changes: 20 additions & 9 deletions translation/zh-CN/manual-zh-CN/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

### 比较文件

```
$ difft sample_files/before.js sample_files/after.js
```bash
$ difft FIRST-FILE SECOND-FILE

$ difft sample_files/simple_1.js sample_files/simple_2.js
```

### 比较文件夹

```
```bash
$ difft FIRST-DIRECTORY SECOND-DIRECTORY

# For example:
$ difft sample_files/dir_1/ sample_files/dir_2/
```

Expand All @@ -22,8 +27,10 @@ Difftastic 会递归地浏览这两个文件夹,对同名的文件进行差异

您可以通过指定 `-` 作为文件路径从标准输入(stdin)读取文件。

```
$ cat sample_files/before.js | difft - sample_files/after.js
```bash
$ difft - SECOND-FILE

$ cat sample_files/simple_1.js | difft - sample_files/simple_2.js
```

### 带冲突标记的文件
Expand All @@ -32,18 +39,22 @@ $ cat sample_files/before.js | difft - sample_files/after.js

如果你有一个带 `<<<<<<<` 冲突标记的文件,可以将它作为一个参数传入 Difftastic。Difftastic 会构建和比较文件的两个状态。

```
```bash
$ difft FILE-WITH-CONFLICTS

$ difft sample_files/conflicts.el
```

## 语言检测

Difftastic 根据文件的扩展名、文件名和第一行的内容猜测文件所用的语言。

你可以通过 `--language` 选项覆盖语言检测。如果输入的文件有所设定的后缀, Difftastic 将会处理它们,并且忽略其他语言。
你可以通过 `--override` 选项覆盖语言检测。如果输入的文件有所设定的后缀, Difftastic 将会处理它们,并且忽略其他语言。

```
$ difft --language cpp before.c after.c
```bash
$ difft --override=GLOB:NAME FIRST-FILE SECOND-FILE

$ difft --override=*.h:c sample_files/preprocesor_1.h sample_files/preprocesor_2.h
```

## 选项
Expand Down

0 comments on commit 5a250d6

Please sign in to comment.