#repeat #cargo #command #right #exit #command-arguments #delay

app cargo-repeat

重复执行命令直到以正确的代码退出

1 个不稳定版本

0.1.0 2022年4月10日

#724Cargo 插件

MIT 许可证

6KB
61

cargo-repeat

重复执行命令直到以正确的代码退出

简介

这个crate是一个小巧实用的函数,允许你无限重复执行一个命令,直到它匹配某个特定的退出代码(默认为0)。

用法

# Output of cargo repeat --help
cargo-repeat 0.1.0
Repeats a command until it exits with the right code

USAGE:
    cargo-repeat.exe [OPTIONS] [-- <TARGET>...]

ARGS:
    <TARGET>...    Command and arguments to repeat

OPTIONS:
    -c, --code <i32>     Exit code to repeat until it's hit [default: 0]
    -h, --help           Print help information
    -s, --sleep <f64>    Delay between retries [default: 1]
    -v, --verbose        Verbose
    -V, --version        Print version information

示例

# Keeps saying "hello world" until it exits with a 0 status
cargo repeat -- echo "hello world"

# Will keep running "python test.py" until it exits with status 5
cargo repeat -c 5 -- python test.py

# Keeps saying "hello" with a 0.5 second delay
cargo repeat -s 0.5 -- echo "hello" 

# Says hello and outputs some statistics at the end
cargo repeat -v -- echo "hello"

依赖

~3MB
~61K SLoC