Skip to content
Snippets Groups Projects
Commit 57a96c02 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

check more args in the benchmarks (dragoon/komodo!187)

this replaces the "_nothing to do_" messages from Nushell commands with more explicite errors.
parent 702cd5eb
No related branches found
No related tags found
1 merge request!187check more args in the benchmarks
Pipeline #6844 passed with stages
in 3 minutes and 42 seconds
......@@ -2,6 +2,7 @@ use utils log
use utils math *
use utils fs check-file
use utils plot [ into-axis-options, COMMON_OPTIONS, gplt ]
use utils args check-list-arg
use std formats *
......@@ -17,10 +18,8 @@ export def run [
]: list<int> -> path {
let input = $in
if ($input | is-empty) or ($curves | is-empty) {
print "nothing to do"
return
}
$curves | check-list-arg --cmd "commit run" --arg "--curves" --span (metadata $curves).span
$in | check-list-arg --cmd "commit run" --arg "pipeline input"
let new_file = $output == null
let output = $output | default (mktemp --tmpdir komodo_commit.XXXXXX)
......
use ../utils log
use ../utils formats *
use ../utils args check-list-arg
use std formats *
......@@ -16,10 +17,9 @@ export def main [
]: list<int> -> path {
let input = $in
if ($ks | is-empty) or ($input | is-empty) or ($curves | is-empty) {
print "nothing to do"
return
}
$ks | check-list-arg --cmd "fec run" --arg "--ks" --span (metadata $ks).span
$curves | check-list-arg --cmd "fec run" --arg "--curves" --span (metadata $curves).span
$in | check-list-arg --cmd "fec run" --arg "pipeline input"
let new_file = $output == null
let output = $output | default (mktemp --tmpdir komodo_fec.XXXXXX)
......
......@@ -88,7 +88,7 @@ export def main [
--dump-dir: path = "./",
] {
if ($x | is-empty) {
error make --unspanned { msg: "nothing to do" }
error make --unspanned { msg: "nothing to do, x is empty" }
}
if $file == null {
error make --unspanned { msg: "missing --file" }
......
......@@ -2,6 +2,7 @@ use utils log
use utils math *
use utils fs check-file
use utils plot [ into-axis-options, COMMON_OPTIONS, gplt ]
use utils args check-list-arg
use std formats *
......@@ -16,10 +17,7 @@ export def run [
]: list<int> -> path {
let input = $in
if ($input | is-empty) {
print "nothing to do"
return
}
$in | check-list-arg --cmd "linalg run" --arg "pipeline input"
let new_file = $output == null
let output = $output | default (mktemp --tmpdir komodo_linalg.XXXXXX)
......
......@@ -3,6 +3,7 @@ use utils formats *
use utils math *
use utils plot [ into-axis-options, COMMON_OPTIONS, gplt ]
use utils fs check-file
use utils args check-list-arg
use std formats *
......@@ -19,10 +20,9 @@ export def run [
]: list<int> -> path {
let input = $in
if ($ks | is-empty) or ($input | is-empty) or ($curves | is-empty) {
print "nothing to do"
return
}
$ks | check-list-arg --cmd "recoding run" --arg "--ks" --span (metadata $ks).span
$curves | check-list-arg --cmd "recoding run" --arg "--curves" --span (metadata $curves).span
$in | check-list-arg --cmd "recoding run" --arg "pipeline input"
let new_file = $output == null
let output = $output | default (mktemp --tmpdir komodo_recoding.XXXXXX)
......
......@@ -2,6 +2,7 @@ use utils log
use utils math *
use utils fs check-file
use utils plot [ into-axis-options, COMMON_OPTIONS, gplt ]
use utils args check-list-arg
use std formats *
......@@ -17,10 +18,8 @@ export def run [
]: list<int> -> path {
let input = $in
if ($input | is-empty) or ($curves | is-empty) {
print "nothing to do"
return
}
$curves | check-list-arg --cmd "setup run" --arg "--curves" --span (metadata $curves).span
$in | check-list-arg --cmd "setup run" --arg "pipeline input"
let new_file = $output == null
let output = $output | default (mktemp --tmpdir komodo_setup.XXXXXX)
......
# throws an error if the input is an empty list
export def check-list-arg [
--cmd: string, # the name of the command
--arg: string, # the name of the argument
--span: record<start: int, end: int>, # the span of the arg (no span means an unspanned error)
]: [ list -> nothing ] {
if ($in | is-empty) {
if $span == null {
error make --unspanned {
msg: $"(ansi red_bold)invalid_arguments(ansi reset)",
help: $"provide a non empty list as ($arg)",
}
} else {
error make {
msg: $"(ansi red_bold)invalid_arguments(ansi reset)",
label: {
text: $"(ansi purple)($cmd)(ansi reset) needs (ansi purple)($arg)(ansi reset)",
span: $span
},
help: $"provide a non empty list as (ansi purple)($arg)(ansi reset)"
}
}
}
}
......@@ -4,3 +4,4 @@ export module log.nu
export module math.nu
export module parse.nu
export module plot.nu
export module args.nu
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment