我们有一些 shell 工具,比如支持嵌套子命令的 makefile 吗?

Do we have some shell tools like makefile that supports nested subcommands?

例如,我只需要像下面这样编辑配置文件:

clean:
  rpc:
    rm -rf ./rpc
  api
    rm -rf ./api

运行:

> make clean rpc

但是,make不支持嵌套子命令。

一个不错的选择是https://github.com/spf13/cobra,它支持subcommandscommand alias...但是它是在golang中使用的,而不是shell。

我想知道 shell 中是否有 cobra

I wonder do we have cobra in shell?

我找到了 1 个,
这是link:https://taskfile.dev/#/

示例如下:

Taskfile.yml

version: "3"

tasks:
  clean:rpc:
    desc: Clean RPC
    cmds:
      - rm -rf ./rpc

  clean:api:
    desc: Clean API
    cmds:
      - rm -rf ./api

查看可用命令:task --list
执行命令:task clean:apitask clean:rpc