#shell #command #task-runner #concurrently #command-name #command-line #parallel

app rly

轻松并行运行shell命令。目前仅提供CLI工具。

2个不稳定版本

0.2.0 2023年1月18日
0.1.0 2023年1月9日

#451 in 并发

Apache-2.0

32KB
564

r[运行并发]ly

Build Status license Version info

rly是一个并发任务运行器,在其当前形式下,基本上是concurrently的克隆。例如

$ rly --names "server,client" \
      --kill-others \
      "nc -lk 1234" \
      "echo 'message from client' | nc localhost 1234"
[server] message from client
[client] echo 'message from client' | nc localhost 1234 exited with exit status: 0
--> Sending SIGKILL to other processes..
[server] nc -lk 1234 exited with signal: 9 (SIGKILL)

安装

目前您需要安装Rust才能安装rly

cargo install rly

用法(进行中)

Usage: rly [OPTIONS] [COMMANDS]...

Arguments:
  [COMMANDS]...


Options:
  -n, --names <NAMES>
          List of custom names to be used in prefix template.

          Example names: "main,browser,server"

      --name-separator <NAME_SEPARATOR>
          The character to split <names> on.

          Example usage: -n "styles|scripts|server" --name-separator
          "|"

          [default: ,]

  -r, --raw
          Output only raw output of processes, disables prettifying
          and concurrently coloring

      --no-color
          Disables colors from logging

      --hide <HIDE>
          Comma-separated list of processes for which to hide the
          output. The processes can be identified by their name or
          index

  -g, --group
          Order the output as if the commands were run sequentially

      --timings
          Show timing information for all processes

  -P, --passthrough-arguments
          Passthrough additional arguments to commands (accessible via
          placeholders) instead of treating them as commands

  -p, --prefix <PREFIX>
          Prefix used in logging for each process. Possible values:
          index, pid, time, command, name, none, or a template.
          Example template: "{time}-{pid}"

          [default: [{name}]]

  -c, --prefix-colors <PREFIX_COLORS>
          Comma-separated list of chalk colors to use on prefixes. If
          there are more commands than colors, the last color will be
          repeated.

          - Available modifiers: reset, bold, dim, italic, underline,
          inverse, hidden, strikethrough

          - Available colors: black, red, green, yellow, blue,
          magenta, cyan, white, gray, any hex values for colors (e.g.
          #23de43) or auto for an automatically picked color

          - Available background colors: bgBlack, bgRed, bgGreen,
          bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite

          See https://npmjs.net.cn/package/chalk for more
          information.

          [default: reset]

  -l, --prefix-length <PREFIX_LENGTH>
          Limit how many characters of the command is displayed in
          prefix. The option can be used to shorten the prefix when it
          is set to "command"

          [default: 10]

  -t, --timestamp-format <TIMESTAMP_FORMAT>
          Specify the timestamp in chrono::format syntax

          [default: "%Y-%m-%d %H:%M:%S.%3f"]

  -k, --kill-others
          Kill other processes if one exits or dies

      --kill-others-on-fail
          Kill other processes if one exits with non zero status code

      --restart-tries <RESTART_TRIES>
          How many times a process that died should restart. Negative
          numbers will make the process restart forever

          [default: 0]

      --restart-after <RESTART_AFTER>
          Delay time to respawn the process, in milliseconds

          [default: 0]

  -h, --help
          Print help information (use `-h` for a summary)

  -V, --version
          Print version information

为什么?

我喜欢concurrently的UX,但不喜欢安装NodeJS / npm来使用它。我的目标是让rly通过Homebrew(以及可能的其它包管理器)可访问,这样安装只需要下载单个二进制文件。

concurrently功能的实现进度

  • 可以提供命令
  • 可以传递--names
  • --name-separator
  • --raw
  • --no-color
  • --hide
  • --group
  • --timings
  • --passthrough-arguments
  • --prefix
    • index
    • pid
    • time
    • command
    • name
  • --prefix-colors
  • --prefix-length
  • --timestamp-format
  • --kill-others
  • --kill-others-on-fail
  • --restart-tries
  • --restart-after

许可证

请参阅LICENSE文件。

依赖

~9–23MB
~296K SLoC