我们是否有一些像Makefile那样支持嵌套子命令的Shell工具?

huangapple go评论79阅读模式
英文:

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,它支持子命令命令别名... 但它是用于golang,而不是shell。

我想知道在shell中是否有cobra

英文:

For example, I just need to edit the config file like the following:

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

run:

> make clean rpc

However, make don't support nested subcommands.

A good choice is https://github.com/spf13/cobra, which supports subcommands and command alias... But it is used in golang, not shell.

I wonder do we havecobra in shell?

答案1

得分: 0

我想知道我们的shell中是否有cobra。

我找到了一个链接,这是链接:https://taskfile.dev/#/

以下是示例:

Taskfile.yml

version: "3"

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

  clean:api:
    desc: 清理API
    cmds:
      - rm -rf ./api

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

英文:

I wonder do we have cobra in shell?

I found 1,<br/>
This is the link: https://taskfile.dev/#/

Below is the example:

Taskfile.yml

version: &quot;3&quot;

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

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

To view available commands: task --list<br/>
To exec command: task clean:api or task clean:rpc

huangapple
  • 本文由 发表于 2022年2月27日 17:18:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/71283528.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定