Search code examples
shellgotaskfile

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


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?


Solution

  • I wonder do we have cobra in shell?

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

    Below is the example:

    Taskfile.yml

    version: "3"
    
    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
    To exec command: task clean:api or task clean:rpc