---
version: '3'

tasks:
  add-trailing-comma:
    tags:
      - update
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: add-trailing-comma

  ansible:
    tags:
      - update
    run: once
    cmds:
      - task: install:pipx
        vars:
          BIN_NAME: ansible
          PACKAGE: ansible-base

  ansible-lint:
    run: once
    tags:
      - semantic
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: ansible-lint

  ansibler:
    tags:
      - update
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: ansibler
      - task: ansible

  black:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: black

  blocklint:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: blocklint

  bundle:
    deps:
      - add-trailing-comma
      - ansible
      - ansible-lint
      - ansibler
      - blocklint
      - flake8
      - isort
      - latestos
      - mod-ansible-autodoc
      - molecule
      - mypy
      - poet
      - pre-commit-hooks
      - proselint
      - pyformat
      - pyinstaller
      - pyinstrument
      - pysnooper
      - pytest
      - pytest-cov
      - toml-sort
      - yamllint

  flake8:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: flake8

  getmac:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: getmac

  install:pipx:
    vars:
      BIN: '{{if .BIN_NAME}}{{.BIN_NAME}}{{else}}{{.PACKAGE}}{{end}}'
    env:
      PATH:
        sh: echo "$PATH:$HOME/.local/bin"
    run: when_changed
    cmds:
      - task: :install:software:pipx
      - .config/log info 'Installing `{{.PACKAGE}}` as a pipx package'
      - |
        PATH="$PATH:$HOME/.local/bin"
        pipx install {{.PACKAGE}} --include-deps --force
      - .config/log success 'Successfully installed `{{.PACKAGE}}` with pipx'
    status:
      - type {{.BIN}} > /dev/null

  isort:
    tags:
      - update
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: isort

  latestos:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: latestos

  mod-ansible-autodoc:
    run: once
    tags:
      - update
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: mod-ansible-autodoc

  molecule:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: molecule

  mypy:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: mypy

  poet:
    tags:
      - update
    run: once
    cmds:
      - task: install:pipx
        vars:
          BIN_NAME: poet
          PACKAGE: homebrew-pypi-poet

  pre-commit-hooks:
    run: once
    cmds:
      - task: install:pipx
        vars:
          BIN_NAME: check-toml
          PACKAGE: pre-commit-hooks
    status:
      - type check-toml &> /dev/null

  proselint:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: proselint

  pyformat:
    tags:
      - update
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: pyformat

  pyinstaller:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: pyinstaller

  pyinstrument:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: pyinstrument

  pysnooper:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: pysnooper

  pytest:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: pytest

  pytest-cov:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: pytest-cov

  toml-sort:
    run: once
    tags:
      - update
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: toml-sort

  yamllint:
    run: once
    cmds:
      - task: install:pipx
        vars:
          PACKAGE: yamllint
