format.sh: add --check
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
This commit is contained in:
parent
25f8607382
commit
0f881800ac
1 changed files with 18 additions and 14 deletions
32
format.sh
32
format.sh
|
@ -1,15 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
yapf \
|
yapf_args=('--recursive' '--parallel')
|
||||||
--recursive \
|
autoflake_args=('--recursive' '--remove-unused-variables' '--remove-all-unused-imports' '--expand-star-imports' '--remove-duplicate-keys')
|
||||||
--in-place \
|
|
||||||
--parallel \
|
format() {
|
||||||
.
|
yapf "${yapf_args[@]}" .
|
||||||
autoflake \
|
autoflake "${autoflake_args[@]}" .
|
||||||
--recursive \
|
}
|
||||||
--in-place \
|
|
||||||
--remove-unused-variables \
|
|
||||||
--remove-all-unused-imports \
|
if [[ "$1" == "--check" ]]; then
|
||||||
--expand-star-imports \
|
yapf_args+=('--diff')
|
||||||
--remove-duplicate-keys \
|
[[ "$(format | tee /dev/stderr | wc -c)" == "0" ]]
|
||||||
.
|
else
|
||||||
|
yapf_args+=('--in-place')
|
||||||
|
autoflake_args+=('--in-place')
|
||||||
|
format
|
||||||
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue