75 releases

0.13.0 Aug 5, 2023
0.12.6-alpha.7 Mar 4, 2023
0.11.4 Mar 2, 2023
0.10.1 Nov 23, 2022
0.5.1 Mar 27, 2020

#477 in Command line utilities

Download history 137/week @ 2024-02-20 118/week @ 2024-02-27 1/week @ 2024-03-12

256 downloads per month

MIT license

63KB
1.5K SLoC

Rust 1K SLoC // 0.0% comments BASH 303 SLoC PowerShell 118 SLoC Elvish 103 SLoC

complate

complate is a general purpose text templating CLI program that supports interactive mode, prompting the user for values via TUI behaviour and headless mode for use in automation such as CI pipelines.

Installation

  • The rusty way:
    cargo install complate
  • The manual way:
    Download and install from the GitHub releases.

Config example

version: 0.13
templates:
  zero:
    content:
      inline: |-
        {{ a.alpha }}
        {{ b.bravo }}
    variables:
      a.alpha:
        static: alpha
      b.bravo: arg

  one:
    content:
      file: ./.complate/templates/arbitraty-template-file.tpl
    variables:
      a.pwd:
        env: "PWD"
  two:
    content:
      inline: |-
        {{ a.alpha }}
        {{ b.bravo }}
        {{ c.charlie }}
        {{ d.delta }}
        {{ e.echo }}
    variables:
      a.alpha:
        prompt: "alpha"
      b.bravo:
        shell: "printf bravo"
      c.charlie:
        static: "charlie"
      d.delta:
        select:
          text: Select the version level that shall be incremented
          options:
            alpha:
              display: alpha
              value:
                static: alpha
            bravo:
              display: bravo
              value:
                shell: printf bravo
      e.echo:
        check:
          text: Select the components that are affected
          separator: ", "
          options:
            alpha:
              display: alpha
              value:
                static: alpha
            bravo:
              display: bravo
              value:
                shell: printf bravo
      f.foxtrot:
        env: "FOXTROT"
  three:
    content:
      inline: |-
        {{ test }}
        {{ _decode "dGVzdA==" }}
    helpers:
      "_decode": printf "$(printf $VALUE | base64 -D)"
    variables:
      test:
        static: "test"

Key Behaviour Input
arg Expects input as argument via command line input None
env Retrieves value from the specified env var None
static Simply replaces the variable with a static value None
prompt Asks the user for text input (can be empty) The prompt
shell Invokes a shell command to resolve the variable (read from STDOUT) None
select Asks the user to select one item from a list text: string (context), options: list (available options to select from)
check Asks the user to select 0..n item(s) from a list (multiselect) text: string (context), options: list of options {display: str, value: str} (the available options to select from)

Since the shell value provider is able to run arbitrary shell commands, it is only allowed if and only if the SHELL_TRUST argument is explicitly set. See the render command reference for possible values for this setting. If not set, the provider will throw an unrecoverable error and the program will abort.

Command reference

Disclaimer

All features that are marked as experimental are not considered a public API and therefore eplicitly not covered by the backwards-compatibility policy inside a major version (see https://semver.org[semver v2]). Use these features on your own risk!

Dependencies

~11–23MB
~309K SLoC