scwrypts/zsh/lib/utils
yage 3fe01a7263 v4.4.0
=====================================================================

Increased non-scwrypts-runtime compatibility and improved clarity
in user environments after sourcing the scwrypts.plugin.zsh.

--- New Features -------------------------

- added experimental support for --output json
- added 'scwrypts --list-groups' to output the SCWRYPTS_GROUPS value
- added 'scwrypts --config' to be `eval`-ed in non-scwrypts-runtime zsh

--- Changes ------------------------------

- removed config variables which pertained to old scwrypts

- removed deprecated --no-log

- cleaned up environment requirements and improved import saftey for
  scwrypts.plugin.zsh; scwrypts is now *required* on $PATH in order to work

- refactored group configuration to match external group configuration
  (configuration now in scwrypts.scwrypts.zsh rather than zsh/lib/config.group.zsh)

- plugins/kubectl now forces an unalias of `f` (for fluxcd) on load

- the 'use' command now supports the '-c' short flag for ease of quick
  use

- upgraded max supported python version to 3.12; dropped support for
  python 3.9 (>3.10 required)

- remove old references to SCWRYPTS_ROOT in favour of SCWRYPTS_ROOT__scwrypts

- SCWRYPTS_LOG_LEVEL setting is now forwarded when using the SCWRYPTS__RUN
  meta execution function
2024-05-08 23:11:09 -06:00
..
colors.zsh v4.0.0 2024-02-20 23:51:32 -07:00
credits.zsh v3.0.0 "The Great Overhaul" 2023-06-21 20:04:30 -06:00
dependencies.zsh v4.1.3 2024-03-11 20:14:44 -06:00
environment.zsh v4.0.0 2024-02-20 23:51:32 -07:00
io.fzf.zsh v4.2.0 2024-04-13 17:34:22 -06:00
io.print.zsh v4.4.0 2024-05-08 23:11:09 -06:00
io.usage.zsh v4.0.0 2024-02-20 23:51:32 -07:00
io.zsh v4.1.0 2024-03-06 11:29:59 -07:00
os.zsh v3.0.0 "The Great Overhaul" 2023-06-21 20:04:30 -06:00
README.md v3.0.0 "The Great Overhaul" 2023-06-21 20:04:30 -06:00
utils.module.zsh v4.4.0 2024-05-08 23:11:09 -06:00

ZSH Utilities

A shell-scripting utilities module made for ZSH. This module is definitely a major component of Scwrypts, but is also standalone and can be sourced by any ZSH script to utilize (almost) all of the features.

Usage

Import utils.module.zsh to activate all of the features. Doing so will also check for path dependencies and required environment variables (see Dependencies and Environment below).

#!/bin/zsh
source ./path/to/utils.plugin.zsh
SUCCESS 'ZSH utilities online!'

Checkout io and os for available simple functions.

Dependencies

Ensures dependent programs are available for execution. Specify a simple name to check the current PATH, or give a fully-qualified path for arbitrary dependency inclusion.

Include a dependency by adding to the DEPENDENCIES array. Always using += makes your dependencies extensible to other scripts :)

If any dependencies are missing, source utils.module.zsh will return an error code and count the number of missing dependencies in the variable DEP_ERROR_COUNT.

#!/bin/zsh
DEPENDENCIES+=(
	path-executable-1
	path-executable-2
	/path/to/arbitrary/program
)
source ./path/to/utils.plugin.zsh
echo "missing $DEP_ERROR required dependencies"

Environment

Similar to Dependencies, environment.zsh ensures a list of environment variables are set to non-empty values.

Include an environment variable by adding to the REQUIRED_ENV array. Something something use += here too ;)

If any environment variables are missing, source utils.module.zsh will return an error code and count the number of missing variables in ENV_ERROR_COUNT.

Missing environment variables will be added to the environment template (exclusive to Scwrypts).

#!/bin/zsh
REQUIRED_ENV+=(
	AWS_PROFILE
	AWS_REGION
)
source ./path/to/utils.plugin.zsh
echo "missing $ENV_ERROR_COUNT required environment variables"