Skip to content

Commit

Permalink
docs: rewrite comments and logo
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidmt committed Feb 2, 2024
1 parent 7ff8297 commit 90f89d4
Showing 1 changed file with 67 additions and 53 deletions.
120 changes: 67 additions & 53 deletions new/modules/.init
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
#!/usr/bin/env sh

#!/usr/bin/env dash
#
# ██████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ███╗██╗ ██╗ ██████╗
# ██╔══██╗██╔══██╗██╔══██╗ ██╗ ██║ ██║████╗ ████║██║ ██║██╔════╝
# ██║ ██║██║ ██║██║ ██║ ██████╗ ███████║██╔████╔██║██║ ██║██║
# ██║ ██║██║ ██║██║ ██║ ╚═██╔═╝ ██╔══██║██║╚██╔╝██║╚██╗ ██╔╝██║
# ██████╔╝██████╔╝██████╔╝ ╚═╝ ██║ ██║██║ ╚═╝ ██║ ╚████╔╝ ╚██████╗
# ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═══╝ ╚═════╝
# ██╗██████╗
# ██████╗ ██╔╝╚════██╗
# ╚═════╝ ██╔╝ █████╔╝
# ██████╗ ╚██╗ ╚═══██╗
# ╚═════╝ ╚██╗██████╔╝
# ╚═╝╚═════╝
# NAME
# DDD + HMVC style Shell/BASH/ZSH modules.
# DDD + HMVC style shell modules
#
# DESCRIPTION
# An HMVC (Hierarchical Model View Controller) style module system for
# organizing shell scripts, functions, variables, etc. Each module is a
# self-contained unit, following a DDD (Domain Driven Design) approach.
# An DDD (Domain Driven Design) and HMVC (Hierarchical Model View Controller)
# style module system for organizing shell scripts, functions, variables, etc.
#
# Each module has its own .init file as entry point to the module's
# functionality and its own .env file for private env data, such as API keys.
# Each module is a self-contained unit, with its own directory, with minimal
# dependencies on other modules.
# Modules have their own .init file as entry point to their functionality.
#
# Example structure:
# @core/
# aws/
# i3/
# openai/
# agents/
# crud/
# schema.sql
# conversations/
# crud/
# schema.sql
# messages/
# crud/
# schema.sql
# config/
# i3blocks/
# toolbars/
# layouts/
# scripts/
# widgets/
# .init
# .env
#
# The i3 module contains everything related to i3. The config file, layouts,
# toolbars, i3blocks widgets, etc.
# Here, the i3 module contains everything related to i3. The config file,
# layouts, toolbars, i3blocks widgets, etc.
#
# This is contrary to the default MVC (Model View Controller) way of
# organizing, that Linux uses, where the config file is in
Expand All @@ -42,18 +49,16 @@
#
# source /path/to/modules/.init
#
# STRUCTURE
#
# Required files and directories:
# .init Entry point file to the module's functionality. Automatically
# REQUIREMENTS
# <.init> Entry point file to the module's functionality. Automatically
# sourced by this file.
#
# RECOMMENDED FOLDER STRUCTURE
# .env File for private env data, such as API keys, passwords, etc.
# Ignored by git.
# .local/ Directory for temporary files and other data. Ignored by git.
# .cache/ Directory for cache files. Ignored by git.
# .tmp/ Directory for temporary files. Ignored by git.
#
# Recommended files and directories:
# scripts/ Directory for scripts. Use module .init to include in $PATH and
# expose shell scripts to the outside world.
# libs/ Directory for libraries. Keep reusable functions ment to be
Expand All @@ -64,40 +69,45 @@
# config/ Directory for config files.
#
# PRECEDENCE
# Modules whose name starts with "@" are loaded first, in alphabetical order.
# The rest of the modules are loaded after, also in alphabetical order.
# This a very light weight way of defining module dependencies.
#
# Modules whose name starts with "@" are loaded first, in alphabetical order.
# The rest of the modules are loaded after, also in alphabetical order.
# This a very light weight way of defining module dependencies.
#
# A common folder structure would be:
# modules/
# @core/
# aws/
# i3/
# ssh/
# A common folder structure would be:
# modules/
# @core/
# aws/
# i3/
# ssh/
#
# The @core module is loaded first, then the rest of the modules, in
# alphabetical order.
# The @core module is loaded first, then the rest of the modules, in
# alphabetical order.
#
# While this will not give the granularity of a full blown dependency manager,
# and allow you to specify if "nvm" depende on "ssh", it should strike a good
# 80/20 balance between simplicity and functionality.
# While this will not give the granularity of a full blown dependency manager,
# and allow you to specify if "nvm" depende on "ssh", it should strike a good
# 80/20 balance between simplicity and functionality.
#
# IGNORED
#
# Modules whose name starts with "_" are ignored and not loaded. This is useful
# when you want to temporarily disable a module without having to delete it.
#
# Modules whose name starts with "_" are ignored and not loaded. This is
# useful when you want to temporarily disable a module without having to
# delete it.

HMVC_HOME="$(dirname "$0")"
HMVC_DEBUG=true
HMVC_LOG="$HMVC_HOME/.logs/hmvc"

# Before anything else, manualy load the @core module to benefit from the
# scripts and functions it provides in this file as well.
# ╭──────────────────────
# │ Before anything else, manualy load the @core module to benefit from the
# │ scripts and functions it provides in this file as well.
# ╰────────

printf "\x1b[1m%b\x1b[0m\n" "󰺔 Loading @core ..."
. "$HMVC_HOME/@core/.init"

# ╭──────────────────────
# │ Helper functions
# ╰────────

# Find all defined modules. Modules whose name starts with "@" are loaded
# first, in alphabetical order, and then the remaining, also in alphabetical
# order.
Expand Down Expand Up @@ -161,9 +171,9 @@ load_module() {
fi
}

##
## Main
##
# ╭──────────────────────
#Main. Start here.
# ╰────────

start_time_main=$(date +%s%N)

Expand All @@ -181,5 +191,9 @@ done
end_time_main=$(date +%s%N)
duration_ms=$(calculate_duration "$start_time_main" "$end_time_main")

figlet -f small "compose"
echo "Loaded $count modules in $(colorize_duration "$duration_ms")"
echo "╭───────────┤ Loaded $count modules"
echo "│ ┓ ┓ ┓ ╻ ┓ ━━ ┏┏┓"
echo "│ ┏┫┏┫┏┫━╋━┣┓┏┳┓┓┏┏━━━┫ ┫"
echo "│ ┗┻┗┻┗┻ ╹ ┛┗┛┗┗┗┛┗━━ ┗┗┛"
echo "╰──┤ $(colorize_duration "$duration_ms")"

0 comments on commit 90f89d4

Please sign in to comment.