Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,28 @@ The certificate is located in `./treafik/ssl/docker.crt` in this repository.

### Bash

You can install completions for `bash` by running:
You can install completions for `bash` by adding

```sh
ln -s $(git rev-parse --show-toplevel)/completion/bash/itkdev-docker-compose-completion.bash $(brew --prefix)/etc/bash_completion.d/itkdev-docker-compose
eval "$(itkdev-docker-compose completions)"
```

to your `~/.bashrc`.

### Zsh

You can install completions for `zsh` by updating `fpath` in `~/.zshrc`, e.g. by running:
Add

```sh
echo "fpath=($(git rev-parse --show-toplevel)/completion/zsh \$fpath) # itkdev-docker " >> ~/.zshrc
# Load completion functions
autoload -Uz +X compinit && compinit
autoload -Uz +X bashcompinit && bashcompinit

eval "$(itkdev-docker-compose completions)"
```

to your `~/.zshrc`. If you are using Oh-My-Zsh, you can leave out the `autoload` incantations.

### Docker UI

If you want a graphical user interface to see what images and containers are
Expand Down
3 changes: 3 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version: "3"

includes:
github-actions: ./task/Taskfile.github-actions.yml
completion:
taskfile: ./completion/Taskfile.yml
dir: ./completion

vars:
GITHUB_ACTIONS_TEMPLATES_HEADER: |
Expand Down
40 changes: 40 additions & 0 deletions completion/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# yaml-language-server: $schema=https://taskfile.dev/schema.json

version: "3"

env:
COMPLETELY_CONFIG_PATH: itkdev-docker-compose.completely.yaml
COMPLETELY_OUTPUT_PATH: itkdev-docker-compose-completion.bash

tasks:
build:
desc: Build completion script for Bash
cmds:
- task: completely
vars:
TASK_ARGS: generate

test:
desc: Template completions
cmds:
# Notice: The completions are not sorted alphabetically when running `completely test`.
- for:
- "itkdev-docker-compose -"
- "itkdev-docker-compose u"
- "itkdev-docker-compose op"
- "itkdev-docker-compose dru"
- "itkdev-docker-compose s"
- "itkdev-docker-compose sy"
- "itkdev-docker-compose sync:"
- "itkdev-docker-compose templa"
- "itkdev-docker-compose template:install -"
- "itkdev-docker-compose template:install "
task: completely
vars:
TASK_ARGS: test '{{.ITEM}}'
silent: true

completely:
desc: Run completely (https://github.com/bashly-framework/completely). Example `{{.TASK}} preview`
cmds:
- docker run --rm --env COMPLETELY_CONFIG_PATH --env COMPLETELY_OUTPUT_PATH --env COMPLETELY_DEBUG --user $(id -u):$(id -g) --volume "$PWD:/app" dannyben/completely {{.TASK_ARGS}} {{.CLI_ARGS}}
20 changes: 0 additions & 20 deletions completion/bash/itkdev-docker-compose-completion.bash

This file was deleted.

69 changes: 69 additions & 0 deletions completion/itkdev-docker-compose-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# itkdev-docker-compose completion -*- shell-script -*-

# This bash completions script was generated by
# completely (https://github.com/bashly-framework/completely)
# Modifying it manually is not recommended

_itkdev-docker-compose_completions_filter() {
local words="$1"
local cur=${COMP_WORDS[COMP_CWORD]}
local result=()

# words the user already typed (excluding the command itself)
local used=()
if ((COMP_CWORD > 1)); then
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
fi

if [[ "${cur:0:1}" == "-" ]]; then
# Completing an option: offer everything (including options)
echo "$words"

else
# Completing a non-option: offer only non-options,
# and don't re-offer ones already used earlier in the line.
for word in $words; do
[[ "${word:0:1}" == "-" ]] && continue

local seen=0
for u in "${used[@]}"; do
if [[ "$u" == "$word" ]]; then
seen=1
break
fi
done
((!seen)) && result+=("$word")
done

echo "${result[*]}"
fi
}

_itkdev-docker-compose_completions() {
local cur=${COMP_WORDS[COMP_CWORD]}
local compwords=()
if ((COMP_CWORD > 0)); then
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
fi
local compline="${compwords[*]}"

COMPREPLY=()

case "$compline" in
'template:install'*)
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_itkdev-docker-compose_completions_filter "--force --list $(itkdev-docker-compose template:install --list-compact 2>/dev/null)")" -- "$cur")
;;

'template:update'*)
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_itkdev-docker-compose_completions_filter "--force")" -- "$cur")
;;

*)
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_itkdev-docker-compose_completions_filter "--help url open drush self:update sync sync:db sync:files sql:cli sql:connect sql:log sql:open sql:port template:install template:update traefik:start traefik:stop traefik:url traefik:open traefik:logs traefik:pull mail:url mail:open mailhog:url mailhog:open xdebug xdebug3 hosts:insert images:pull shell composer php down version")" -- "$cur")
;;

esac
} &&
complete -F _itkdev-docker-compose_completions itkdev-docker-compose

# ex: filetype=sh
173 changes: 173 additions & 0 deletions completion/itkdev-docker-compose.completely.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# https://github.com/bashly-framework/completely?tab=readme-ov-file#configuration-syntax

itkdev-docker-compose:
- --help

# url [service [port]]
# Print url to site or a service
#
# Protip: run
#
# brew install jq
#
# for improved handling of Traefik host names using jq (https://stedolan.github.io/jq/).
- url

# open [service [port]]
# Open url in default browser
- open

# drush
# Run drush command. If drush in installed via composer,
# the vendor/bin/drush command is run inside the phpfpm
# container. Otherwise, the drush container is used to
# run the command.
- drush

# self:update
# Update this script and other stuff.
- self:update

# sync
# Sync both database and files.
- sync

# sync:db
# Sync database base on 'REMOTE_DB_DUMP_CMD' in the env
# file.
#
# If 'SYNC_DB_POST_SCRIPT' is set, it will be eval'ed after
# importing the remote database.
- sync:db

# sync:files
# Sync files base on 'REMOTE_PATH' or 'LOCAL_PATH' in
# the env file.
- sync:files

# sql:cli
# Open MySQL client to the database (named `db`) in the database
# container (`mariadb`).
#
# Execute a SQL query from the command line:
#
# itkdev-docker-compose sql:cli --table <<< 'SHOW TABLES'
#
# Run a SQL script:
#
# itkdev-docker-compose sql:cli < query.sql
- sql:cli

# sql:connect
# Print mysql command for connecting to database (named
# `db`) in the database container (`mariadb`).
#
# Use `$(itkdev-docker-compose sql:connect)` to open the
# database cli.
- sql:connect

# sql:log
# Log SQL queries sent to database.
- sql:log

# sql:open
# Open database GUI and connect to MariaDB.
- sql:open

# sql:port
# Display the exposed MariaDB SQL server port.
- sql:port

# template:install name [--force] [--list]
# Install a named docker-composer template in the current
# directory.
- template:install:
- --force
- --list
- $(itkdev-docker-compose template:install --list-compact 2>/dev/null)

# template:update [--force]
# Update template installed in project.
- template:update:
- --force

# traefik:start
# Start traefik reverse proxy.
- traefik:start

# traefik:stop
# Stop traefik reverse proxy
- traefik:stop

# traefik:url
# URL for the administrative UI for traefik.
- traefik:url

# traefik:open
# Open the administrative UI for traefik.
- traefik:open

# traefik:logs
# See traefik logs
- traefik:logs

# traefik:pull
# Pull latest traefik & socket-proxy containers
- traefik:pull

# mail:url
# URL for the test mail web interface.
- mail:url

# mail:open
# Open test mail web interface in default browser.
- mail:open

# mailhog:url
# URL for the mailhog web-interface.
- mailhog:url

# mailhog:open
# Open mailhog url in default browser
- mailhog:open

# xdebug
# Boot the containers with PHP xdebug support enabled.
- xdebug

# xdebug3
# Boot the containers with PHP xdebug support enabled.
# Consider using `xdebug` for an improved developer experience.
- xdebug3

# hosts:insert
# Insert the docker site url into the hosts file.
- hosts:insert

# images:pull
# Update/pull all docker images.
- images:pull

# shell [service name]
# Enter into /usr/bin/env sh inside container. E.g. itkdev-docker-compose shell phpfpm
- shell

# composer
# Run composer command inside phpfpm container
- composer

# php
# Run php command inside phpfpm container
- php

# bin/*
# vendor/bin/*
# Run command command inside phpfpm container

# down
# Stop and remove containers, networks, images, and volumes
- down

# version
# Display this tool's current version
- version
Loading