17 lines
584 B
Plaintext
17 lines
584 B
Plaintext
|
|
#!/usr/bin/env nu
|
||
|
|
# lint.nu — run cargo clippy on the crate in the current directory.
|
||
|
|
# Reads JSON inputs from stdin. Emits JSON result to stdout.
|
||
|
|
|
||
|
|
def main []: nothing -> nothing {
|
||
|
|
let inputs = ($in | from json)
|
||
|
|
let crate_path = ($inputs | get --ignore-errors crate_path | default ".")
|
||
|
|
|
||
|
|
let result = (do { ^cargo clippy --all-features -- -D warnings } | complete)
|
||
|
|
|
||
|
|
let ok = ($result.exit_code == 0)
|
||
|
|
let warnings = if $ok { 0 } else { 1 }
|
||
|
|
let errors = if $ok { 0 } else { 1 }
|
||
|
|
|
||
|
|
{ "linted-code": { ok: $ok, warnings: $warnings, errors: $errors } } | to json | print
|
||
|
|
}
|