Skip to content

Commit 8c3c5bc

Browse files
committed
Improve CLI file argument default value to ..
Before `aucorrect --lint ./`, Now just `autocorrect --lint`, default path in current path.
1 parent 76ee3f8 commit 8c3c5bc

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ LAST_TAG_VERSION=$(shell git describe --abbrev=0 --tags | sed "s/^v//")
44
bench:
55
rustup run nightly cargo bench --features bench
66
run:
7-
cargo run -- --debug --lint ./
7+
cargo run -- --lint
88
run\:json:
9-
cargo run -- --lint --format json ./
9+
cargo run -- --lint --format json
1010
build:
1111
cargo build --release --target aarch64-apple-darwin
1212
sudo ln -f target/aarch64-apple-darwin/release/autocorrect /usr/local/bin/autocorrect
1313
test:
1414
@cargo test --manifest-path autocorrect/Cargo.toml
1515
@cargo test
1616
test\:lint:
17-
@cargo run -q -- --debug --lint tests/fixtures/*.fixed.*
17+
@cargo run -q -- --lint tests/fixtures/*.fixed.*
1818
test\:bench:
1919
tests/bench.sh
2020
test\:lint-json:

README.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,28 @@ $ curl -sSL https://git.io/JcGER | bash
4747
after that, you will get `/usr/local/bin/autocorrect` command.
4848

4949
```bash
50-
AutoCorrect 1.0.0
50+
AutoCorrect
5151
52-
Automatically add whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters,
53-
numerical digits and symbols).
52+
A linter and formatter for help you improve copywriting, to correct spaces, punctuations between CJK (Chinese, Japanese,
53+
Korean).
5454

5555
USAGE:
5656
autocorrect [FLAGS] [OPTIONS] [file]...
5757

5858
FLAGS:
59+
--debug Print debug message.
60+
--type Directly use set file type
5961
--fix Automatically fix problems and rewrite file.
6062
-h, --help Prints help information
6163
--lint Lint and output problems.
6264
-V, --version Prints version information
6365

6466
OPTIONS:
65-
--type <filetype> Directly use set file type [default: ]
6667
--format <formatter> Choose an output formatter. [default: diff] [possible values: json, diff]
68+
--threads <threads> Number of threads, 0 - use number of CPU [default: 0]
6769

6870
ARGS:
69-
<file>... Target filepath or dir for format
71+
<file>... Target filepath or dir for format [default: .]
7072
```
7173

7274
## Usage
@@ -86,7 +88,7 @@ $ autocorrect text.txt
8688

8789
$ autocorrect --fix text.txt
8890
$ autocorrect --fix zh-CN.yml
89-
$ autocorrect --fix ./
91+
$ autocorrect --fix
9092
```
9193

9294
#### Lint
@@ -106,7 +108,7 @@ $ autocorrect --lint text.txt
106108
You also can lint multiple files:
107109

108110
```bash
109-
$ autocorrect --lint .
111+
$ autocorrect --lint
110112
```
111113

112114
### Ignore option
@@ -172,7 +174,7 @@ autocorrect:
172174
stage: build
173175
image: huacnlee/autocorrect:latest
174176
script:
175-
- autocorrect --lint .
177+
- autocorrect --lint
176178
# Enable allow_failure if you wants.
177179
# allow_failure: true
178180
```

autocorrect-cli/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ fn get_matches<'a>() -> clap::ArgMatches<'a> {
2626
.version(crate_version!())
2727
.about("A linter and formatter for help you improve copywriting, to correct spaces, punctuations between CJK (Chinese, Japanese, Korean).")
2828
.arg(
29-
Arg::with_name("file").help("Target filepath or dir for format").takes_value(true).required(true).multiple(true)
29+
Arg::with_name("file").help("Target filepath or dir for format").takes_value(true).default_value(".").multiple(true)
3030
)
3131
.arg(
32-
Arg::with_name("fix").long("fix").help("Automatically fix problems and rewrite file.").required(false)
32+
Arg::with_name("fix").long("fix").help("Automatically fix problems and rewrite file.")
3333
)
3434
.arg(
3535
Arg::with_name("lint").long("lint").help("Lint and output problems.")
3636
)
3737
.arg(
38-
Arg::with_name("filetype").long("type").help("Directly use set file type").required(false)
38+
Arg::with_name("filetype").long("type").help("Directly use set file type")
3939
)
4040
.arg(
41-
Arg::with_name("formatter").long("format").help("Choose an output formatter.").default_value("diff").possible_values(&["json", "diff"]).required(false)
41+
Arg::with_name("formatter").long("format").help("Choose an output formatter.").default_value("diff").possible_values(&["json", "diff"])
4242
)
4343
.arg(
4444
Arg::with_name("debug").long("debug").help("Print debug message.")
4545
)
4646
.arg(
47-
Arg::with_name("threads").long("threads").help("Number of threads, 0 - use number of CPU").default_value("0").required(false)
47+
Arg::with_name("threads").long("threads").help("Number of threads, 0 - use number of CPU").default_value("0")
4848
)
4949
.get_matches();
5050
}

0 commit comments

Comments
 (0)