33 lines
801 B
Plaintext
33 lines
801 B
Plaintext
export def wait-for [wait_time:duration] {
|
|
let steps = $wait_time / 1sec
|
|
seq 0 $steps | each { |i|
|
|
print -n -e $"(ansi erase_entire_line)\r($wait_time - ($i * 1sec))"
|
|
sleep 1sec
|
|
}
|
|
print ""
|
|
}
|
|
|
|
export def wait-until [call, --step-time:duration, --overall:duration] {
|
|
let input_stream = $in
|
|
let end_time = (date now) + $overall
|
|
loop {
|
|
if (do $call $input_stream) {
|
|
return true
|
|
}
|
|
|
|
if ($end_time < (date now)) {
|
|
return false
|
|
}
|
|
|
|
wait-for $step_time
|
|
}
|
|
}
|
|
|
|
export def "progressed-each" [call] {
|
|
let stream = ($in)
|
|
let overall = ($stream | length)
|
|
$stream | enumerate | each { |x|
|
|
print -n -e $"(ansi erase_entire_line)\r($x.index)/($overall)"
|
|
do $call $x.item
|
|
}
|
|
} |