From 97d884232ec969602ec6294d6df944b35e2cd147 Mon Sep 17 00:00:00 2001 From: vitali87 Date: Fri, 27 Mar 2026 21:54:27 +0100 Subject: [PATCH] feat: add mk env entity for generating .env files from templates --- lib/completions.sh | 6 ++-- lib/make.sh | 31 ++++++++++++++++ test.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 2 deletions(-) diff --git a/lib/completions.sh b/lib/completions.sh index aa5d9c7..049fe40 100644 --- a/lib/completions.sh +++ b/lib/completions.sh @@ -2,10 +2,10 @@ _u7_complete_entities() { local verb="$1" cur="$2" case "$verb" in show|sh) - COMPREPLY=($(compgen -W "ip csv json line ssl files diff cpu memory disk processes port usage network git env http docker system definition functions --help" -- "$cur")) + COMPREPLY=($(compgen -W "ip csv json line ssl files diff cpu memory disk processes ports port usage network git env http docker system definition functions --help" -- "$cur")) ;; make|mk) - COMPREPLY=($(compgen -W "dir file password user copy link archive clone template sequence --help" -- "$cur")) + COMPREPLY=($(compgen -W "dir file password user copy link archive clone template sequence env --help" -- "$cur")) ;; drop|dr) COMPREPLY=($(compgen -W "file dir dirs files line lines column duplicates process user docker --help" -- "$cur")) @@ -38,12 +38,14 @@ _u7_complete_args() { env) COMPREPLY=($(compgen -W "match" -- "$cur")) ;; http) COMPREPLY=($(compgen -W "get head headers" -- "$cur")) ;; docker) COMPREPLY=($(compgen -W "containers images volumes networks all" -- "$cur")) ;; + ports) COMPREPLY=($(compgen -W "match" -- "$cur")) ;; *) _filedir ;; esac ;; make|mk) case "$entity" in copy|link) _filedir ;; + env) COMPREPLY=($(compgen -W "from" -- "$cur")) ;; template) COMPREPLY=($(compgen -W "python node bash web" -- "$cur")) ;; esac ;; diff --git a/lib/make.sh b/lib/make.sh index c349105..ab30554 100644 --- a/lib/make.sh +++ b/lib/make.sh @@ -170,6 +170,36 @@ _u7_make() { esac ;; + env) + local template=".env.example" + local output=".env" + + if [[ "$1" == "from" ]]; then + if [[ -z "$2" ]]; then + echo "Usage: u7 mk env from