Skip to content

Commit 44fcadf

Browse files
authored
Improvements to parse-all/summary commands in toolkit.nu (#25)
1. Fix the type annotations in parse-all 2. Accept the input through piper in summary 3. Allow to customize the binary in parse-all
1 parent 820deb3 commit 44fcadf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

toolkit.nu

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ export def span [span_start: int, span_end: int]: string -> nothing {
2121
# $ parse-all example.nu ../nu_scripts/
2222
export def parse-all [
2323
--verbose (-v)=false # Print the file name before parsing (useful when parser hangs)
24+
--binary (-b)='./target/debug/new-nu-parser' # The path to new-nu-parser binary
2425
...sources: string # The list of nu scripts and directories to parse
25-
] -> list<record<file: string, exit_code: int, time: duration>> {
26+
] (nothing -> list<record<file: string, exit_code: int, time: duration>>) {
2627
let files = $sources | each { |$source|
2728
if ($source | path type) == "dir" {
2829
glob ($source | path join "**/*.nu")
@@ -36,7 +37,7 @@ export def parse-all [
3637
}
3738
mut output = {}
3839
let time = timeit {
39-
let ret = (./target/debug/new-nu-parser $file | complete)
40+
let ret = (^$"($binary)" $file | complete)
4041
$output = $ret
4142
}
4243
{
@@ -50,8 +51,9 @@ export def parse-all [
5051
# Summarizes the output produced by `parse-all` command.
5152
#
5253
# Example usage:
53-
# $ summary (parse-all ../nu_scripts/)
54-
export def summary [report: list<record<file: string, exit_code: int, time: duration>>] {
54+
# $ parse-all ../nu_scripts/ | summary
55+
export def summary [] (list<record<file: string, exit_code: int, time: duration>> -> string) {
56+
let report = $in;
5557
let errors = $report | where exit_code == 1
5658
let crashes = $report | where exit_code != 0 and exit_code != 1
5759
let slowest = $report | sort-by time | last

0 commit comments

Comments
 (0)