跳转到主要内容

简化容器使用

项目描述

入门

Makim (或 makim) 基于 make 并专注于改进定义任务和依赖关系的方式。它使用 yaml 格式,而不是 Makefile 格式。

本项目的想法是提供一种带有一些控制选项(如条件 if)定义任务和依赖关系的方法。

它允许以非常简单的方式定义文档中的文本和每个任务的额外参数。

功能

  • .makim.yaml 规范中,帮助文本作为一等公民。它可以由任务和参数使用。
  • 任务具有参数选项。
  • 任务具有依赖关系选项。
  • 依赖关系可以调用具有特定参数的任务。
  • 依赖关系可以有条件控制流(if)。
  • 允许创建组,因此可以根据主题组织任务。
  • 任务和组可以选择用户定义变量和/或环境变量。
  • 通过模板(使用 Jinja2)访问参数、变量或环境变量。
  • 使用 env-file 键选择使用点环境文件。

如何使用它

首先,您需要将配置文件 .makim.yaml 放置在项目根目录下。这是一个配置文件的示例

version: 1.0.0
groups:
  default:
    env-file: .env
    tasks:
      clean:
        help: Use this task to clean up temporary files
        args:
          all:
            type: bool
            action: store_true
            help: Remove all files that are tracked by git
        run: |
          echo "remove file X"
      build:
        help: Build the program
        args:
          clean:
            type: bool
            action: store_true
            help: if not set, the clean dependency will not be triggered.
        dependencies:
          - task: clean
            if: {% raw %}${{ args.clean == true }}{% endraw %}
        run: |
          echo "build file x"
          echo "build file y"
          echo "build file z"

一些使用示例

  • 运行 build 任务: makim build

  • 运行 clean 任务: makim clean

  • 运行带有 clean 标志的 build 任务: makim build --clean

.makim.yaml 文件的帮助菜单如下所示

$ makim --help
usage: MakIm [--help] [--version] [--config-file MAKIM_FILE] [task]

MakIm is a tool that helps you to organize and simplify your helper commands.

positional arguments:
  task
    Specify the task command to be performed. Options are:

    default:
    --------
      default.clean => Use this task to clean up temporary files
        ARGS:
          --all: (bool) Remove all files that are tracked by git
      default.build => Build the program
        ARGS:
          --clean: (bool) if not set, the clean dependency will not be triggered.

options:
  --help, -h
    Show the help menu
  --version
    Show the version of the installed MakIm tool.
  --config-file MAKIM_FILE
    Specify a custom location for the config file.

If you have any problem, open an issue at: https://github.com/osl-incubator/makim

如您所见,帮助菜单会自动将 .makim.yaml 文件中定义的所有 help 键信息添加进来。

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面