Skip to content

Commit

Permalink
Improve CLI file argument default value to ..
Browse files Browse the repository at this point in the history
Before `aucorrect --lint ./`, Now just `autocorrect --lint`, default path in current path.
  • Loading branch information
huacnlee committed Apr 12, 2022
1 parent 76ee3f8 commit 8c3c5bc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ LAST_TAG_VERSION=$(shell git describe --abbrev=0 --tags | sed "s/^v//")
bench:
rustup run nightly cargo bench --features bench
run:
cargo run -- --debug --lint ./
cargo run -- --lint
run\:json:
cargo run -- --lint --format json ./
cargo run -- --lint --format json
build:
cargo build --release --target aarch64-apple-darwin
sudo ln -f target/aarch64-apple-darwin/release/autocorrect /usr/local/bin/autocorrect
test:
@cargo test --manifest-path autocorrect/Cargo.toml
@cargo test
test\:lint:
@cargo run -q -- --debug --lint tests/fixtures/*.fixed.*
@cargo run -q -- --lint tests/fixtures/*.fixed.*
test\:bench:
tests/bench.sh
test\:lint-json:
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,28 @@ $ curl -sSL https://git.io/JcGER | bash
after that, you will get `/usr/local/bin/autocorrect` command.

```bash
AutoCorrect 1.0.0
AutoCorrect
Jason Lee <[email protected]
Automatically add whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters,
numerical digits and symbols).
A linter and formatter for help you improve copywriting, to correct spaces, punctuations between CJK (Chinese, Japanese,
Korean).

USAGE:
autocorrect [FLAGS] [OPTIONS] [file]...

FLAGS:
--debug Print debug message.
--type Directly use set file type
--fix Automatically fix problems and rewrite file.
-h, --help Prints help information
--lint Lint and output problems.
-V, --version Prints version information

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

ARGS:
<file>... Target filepath or dir for format
<file>... Target filepath or dir for format [default: .]
```

## Usage
Expand All @@ -86,7 +88,7 @@ $ autocorrect text.txt

$ autocorrect --fix text.txt
$ autocorrect --fix zh-CN.yml
$ autocorrect --fix ./
$ autocorrect --fix
```

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

```bash
$ autocorrect --lint .
$ autocorrect --lint
```

### Ignore option
Expand Down Expand Up @@ -172,7 +174,7 @@ autocorrect:
stage: build
image: huacnlee/autocorrect:latest
script:
- autocorrect --lint .
- autocorrect --lint
# Enable allow_failure if you wants.
# allow_failure: true
```
Expand Down
10 changes: 5 additions & 5 deletions autocorrect-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ fn get_matches<'a>() -> clap::ArgMatches<'a> {
.version(crate_version!())
.about("A linter and formatter for help you improve copywriting, to correct spaces, punctuations between CJK (Chinese, Japanese, Korean).")
.arg(
Arg::with_name("file").help("Target filepath or dir for format").takes_value(true).required(true).multiple(true)
Arg::with_name("file").help("Target filepath or dir for format").takes_value(true).default_value(".").multiple(true)
)
.arg(
Arg::with_name("fix").long("fix").help("Automatically fix problems and rewrite file.").required(false)
Arg::with_name("fix").long("fix").help("Automatically fix problems and rewrite file.")
)
.arg(
Arg::with_name("lint").long("lint").help("Lint and output problems.")
)
.arg(
Arg::with_name("filetype").long("type").help("Directly use set file type").required(false)
Arg::with_name("filetype").long("type").help("Directly use set file type")
)
.arg(
Arg::with_name("formatter").long("format").help("Choose an output formatter.").default_value("diff").possible_values(&["json", "diff"]).required(false)
Arg::with_name("formatter").long("format").help("Choose an output formatter.").default_value("diff").possible_values(&["json", "diff"])
)
.arg(
Arg::with_name("debug").long("debug").help("Print debug message.")
)
.arg(
Arg::with_name("threads").long("threads").help("Number of threads, 0 - use number of CPU").default_value("0").required(false)
Arg::with_name("threads").long("threads").help("Number of threads, 0 - use number of CPU").default_value("0")
)
.get_matches();
}
Expand Down

0 comments on commit 8c3c5bc

Please sign in to comment.