-
Notifications
You must be signed in to change notification settings - Fork 9
/
toolkit.nu
77 lines (70 loc) · 2.32 KB
/
toolkit.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# this module regroups a bunch of development tools to make the development
# process easier for anyone.
#
# the main purpose of `toolkit` is to offer an easy to use interface for the
# developer during a PR cycle, namely to (**1**) format the source base,
# (**2**) catch classical flaws in the new changes with *clippy* and (**3**)
# make sure all the tests pass.
# print the pipe input inside backticks, dimmed and italic, as a pretty command
def pretty-print-command [] {
$"`(ansi default_dimmed)(ansi default_italic)($in)(ansi reset)`"
}
# check standard code formatting and apply the changes
export def fmt [
--check # do not apply the format changes, only check the syntax
--verbose # print extra information about the command's progress
] {
if $verbose {
print $"running ('toolkit fmt' | pretty-print-command)"
}
if $check {
try {
cargo fmt --all -- --check
} catch {
error make --unspanned {
msg: $"\nplease run ('toolkit fmt' | pretty-print-command) to fix formatting!"
}
}
} else {
cargo fmt --all
}
}
# check that you're using the standard code style
#
# > it is important to make `clippy` happy :relieved:
export def clippy [
--verbose # print extra information about the command's progress
] {
if $verbose {
print $"running ('toolkit clippy' | pretty-print-command)"
}
try {(
cargo clippy
--all-targets
--no-deps
--workspace
--
-D warnings
-D rustdoc::broken_intra_doc_links
-W clippy::explicit_iter_loop
-W clippy::explicit_into_iter_loop
-W clippy::semicolon_if_nothing_returned
-W clippy::doc_markdown
-W clippy::manual_let_else
)} catch {
error make --unspanned {
msg: $"\nplease fix the above ('clippy' | pretty-print-command) errors before continuing!"
}
}
}
# check that all the tests pass
export def test [
--fast # use the "nextext" `cargo` subcommand to speed up the tests (see [`cargo-nextest`](https://nexte.st/) and [`nextest-rs/nextest`](https://github.com/nextest-rs/nextest))
] {
if $fast {
cargo nextest run --all
} else {
cargo test --workspace
}
}
export def main [] { help toolkit }