Skip to content

hobnob

Another YAML task runner, except…

Tasks return values, prompts are steps and JSON stays data. It reads like a book, and runs like one.

bash
curl -fsSL https://github.com/jakesmd/hobnob/releases/latest/download/install.sh | bash

One static binary. On CI, add it to GitHub Actions.

↩️

Tasks return values

Query an API from any step, then use the response for the rest of the run.

📝

Prompts are just steps

A text box, a menu or a multi-select, built from an earlier step's output.

🧬

JSON is data, not text

Dot into it ten steps later, at any depth. No parsing step.

🧭

Nothing to memorize

Bare hobnob opens a menu of tasks, and whatever a task needs, it prompts for.

Terminalhobnob.yml
$
yaml
tasks:
  ask-trivia:
    info: Answer a trivia question from a category you pick.
    steps:
      # Query an API. The response is a value now.
      - run: curl -fsS https://the-trivia-api.com/v2/categories
        into:
          - CATEGORIES: stdout

      # The menu is built from what that step returned.
      - get:
          - CATEGORY:
              info: Which category?
              options: .CATEGORIES | keys

      # Look up the chosen category's id by name.
      - run: curl -fsS "https://the-trivia-api.com/v2/questions?limit=1&categories={{ .CATEGORIES[.CATEGORY][0] }}"
        into:
          - TRIVIA: stdout[0]

      # Shuffle the answers, so the right one isn't always first.
      - run: [sh, -c, 'printf "%s\n" "$@" | sort -R', answers, .TRIVIA.correctAnswer, .TRIVIA.incorrectAnswers]
        into:
          - ANSWERS: stdout | lines

      # Dot straight into the JSON. No parsing step.
      - get:
          - GUESS:
              info: "{{ .TRIVIA.question.text }}"
              options: .ANSWERS

      - run: echo "Correct!"
        if: "{{ eq .GUESS (.TRIVIA.correctAnswer | trim) }}"
      - run: 'echo "Not quite. It was {{ .TRIVIA.correctAnswer | trim }}."'
        if: "{{ ne .GUESS (.TRIVIA.correctAnswer | trim) }}"

Live, in your browser: the questions come straight from the API.

Ready to write your own?

Released under the BSD-3-Clause License.