Compare commits

...

8 Commits

Author SHA1 Message Date
97d99b7957
upd: root/file updated
root files updated
2026-08-28 11:36:21 +08:00
957befecbd
upd: root/file updated
module name updated
2026-08-28 11:31:11 +08:00
c86d375869
upd: root/file updated
readme updated
2026-08-28 11:17:30 +08:00
9148cde3a3
upd: root/file updated
changelog updated
2026-08-28 11:16:46 +08:00
9902c4e86f
upd: root/file updated
license updated
2026-08-28 11:15:41 +08:00
ce3e62d23e
upd: root/file updated
makefile updated
2026-08-28 11:14:41 +08:00
74fcc7c6c1
upd: root/file updated
gitignore updated
2026-08-28 11:13:29 +08:00
042b7bbe0e
upd: root/file
branched from main
2026-08-28 10:49:45 +08:00
6 changed files with 579 additions and 0 deletions

27
.gitignore vendored
View File

@ -0,0 +1,27 @@
# Environment
.env
.env/
# Temporary
.tmp
*.tmp
.tmp/
# Backup
.bkp
*.bkp
.bkp/
# Archives
*.zip
*.tar
*.tar.gz
*.tgz
*.gz
*.bz2
*.tar.bz2
*.xz
*.tar.xz
*.7z
*.rar
*.Z

View File

@ -0,0 +1,20 @@
# Change Log
Description
## [Version] - [Date]
### Added
- [Title]
Short Description
### Changed
- [Title]
Short Description
### Fixed
- [Title]
Short Description

View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2026 Startupore
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

284
Makefile
View File

@ -0,0 +1,284 @@
# =========================================================
# Variable
# =========================================================
# Framework
# Identity and metadata of framework. Human-readable name, machine-readable names(lower and upper), and semantic version.
FRAMEWORK_REGULAR=Framework Regular
FRAMEWORK_LOWER=frameworklower
FRAMEWORK_UPPER=FRAMEWORKUPPER
FRAMEWORK_VERSION=0.0.0
# Software
# Identity and metadata of software. Human-readable name, machine-readable names(lower and upper), and semantic version.
SOFTWARE_REGULAR=Software Regular
SOFTWARE_LOWER=softwarelower
SOFTWARE_UPPER=SOFTWAREUPPER
SOFTWARE_VERSION=0.0.0
# Go Module
# App module and import path used by go.mod and source imports. Valid Go module path.
GO_MODULE=go/module
# Directory
# Locations used by build and management commands. Relative or absolute paths.
SOURCE_DIR=./run/main
RELEASE_DIR=./release
FRAMEWORK_METADATA_DIR=./data/framework/metadata
SOFTWARE_METADATA_DIR=./data/software/metadata
# File
# Metadata file names without extension. File name only.
FRAMEWORK_METADATA_FLE=resource
SOFTWARE_METADATA_FLE=resource
# Derived Path
# Automatically generated from directory and file variables. Do not edit.
FRAMEWORK_METADATA_PATH=$(FRAMEWORK_METADATA_DIR)/$(FRAMEWORK_METADATA_FLE)
SOFTWARE_METADATA_PATH=$(SOFTWARE_METADATA_DIR)/$(SOFTWARE_METADATA_FLE)
# Target File Type
# File types scanned by update commands. Valid find expression.
TARGET_FILE_TYPE=\
-name "*.go" \
-o -name "*.json" \
-o -name "*.yaml" \
-o -name "*.yml"
# Go Module Placeholder
# Replacement rules applied by upd-gm-ph. Valid sed replacement expressions.
GO_MODULE_REPLACEMENT=\
-e 's|gomodule|$(GO_MODULE)|g' \
-e 's|go/module|$(GO_MODULE)|g' \
-e 's|go-module|$(GO_MODULE)|g' \
-e 's|go_module|$(GO_MODULE)|g'
# =========================================================
# Command
# =========================================================
# PHONY Target
.PHONY: \
help \
upd-gm-ph \
upd-fw-md \
upd-sw-md \
go-ini \
go-tid \
go-stp \
pre-rel \
go-bld \
go-bld-lin \
go-bld-win \
go-bld-mac \
bld-lin-amd \
bld-lin-arm \
bld-win-amd \
bld-win-arm \
bld-mac-amd \
bld-mac-arm
# Default Command
.DEFAULT_GOAL := help
# =========================================================
# Help
# =========================================================
help:
@echo ""
@echo "Available Commands:"
@echo ""
@printf " %-18s %s\n" "upd-gm-ph" "Update Go module placeholder"
@printf " %-18s %s\n" "upd-fw-md" "Update framework metadata"
@printf " %-18s %s\n" "upd-sw-md" "Update software metadata"
@echo ""
@printf " %-18s %s\n" "go-ini" "Initialize Go module"
@printf " %-18s %s\n" "go-tid" "Tidy Go module dependencies"
@printf " %-18s %s\n" "go-stp" "Initialize Go module and tidy dependencies"
@echo ""
@printf " %-18s %s\n" "go-bld" "Build all platform binaries"
@printf " %-18s %s\n" "go-bld-lin" "Build all Linux binaries"
@printf " %-18s %s\n" "go-bld-win" "Build all Windows binaries"
@printf " %-18s %s\n" "go-bld-mac" "Build all macOS binaries"
@echo ""
@printf " %-18s %s\n" "bld-lin-amd" "Build Linux AMD64 binary"
@printf " %-18s %s\n" "bld-lin-arm" "Build Linux ARM64 binary"
@echo ""
@printf " %-18s %s\n" "bld-win-amd" "Build Windows AMD64 binary"
@printf " %-18s %s\n" "bld-win-arm" "Build Windows ARM64 binary"
@echo ""
@printf " %-18s %s\n" "bld-mac-amd" "Build macOS AMD64 binary"
@printf " %-18s %s\n" "bld-mac-arm" "Build macOS ARM64 binary"
@echo ""
# =========================================================
# Update
# =========================================================
upd-gm-ph:
@find . -type f \
\( $(TARGET_FILE_TYPE) \) \
-exec sed -i \
$(GO_MODULE_REPLACEMENT) \
{} +
@if [ -f go.mod ]; then \
sed -i \
$(GO_MODULE_REPLACEMENT) \
go.mod; \
fi
@go mod tidy
@echo "Go Module Updated!"
upd-fw-md:
@jq \
--arg framework_regular "$(FRAMEWORK_REGULAR)" \
--arg framework_lower "$(FRAMEWORK_LOWER)" \
--arg framework_upper "$(FRAMEWORK_UPPER)" \
--arg framework_version "$(FRAMEWORK_VERSION)" \
'.framework.regular=$$framework_regular|.framework.lower=$$framework_lower|.framework.upper=$$framework_upper|.framework.version=$$framework_version' \
$(FRAMEWORK_METADATA_PATH).json \
> $(FRAMEWORK_METADATA_PATH).json.tmp
@mv $(FRAMEWORK_METADATA_PATH).json.tmp $(FRAMEWORK_METADATA_PATH).json
@echo "Framework Metadata Updated!"
upd-sw-md:
@jq \
--arg software_regular "$(SOFTWARE_REGULAR)" \
--arg software_lower "$(SOFTWARE_LOWER)" \
--arg software_upper "$(SOFTWARE_UPPER)" \
--arg software_version "$(SOFTWARE_VERSION)" \
'.software.regular=$$software_regular|.software.lower=$$software_lower|.software.upper=$$software_upper|.software.version=$$software_version' \
$(SOFTWARE_METADATA_PATH).json \
> $(SOFTWARE_METADATA_PATH).json.tmp
@mv $(SOFTWARE_METADATA_PATH).json.tmp $(SOFTWARE_METADATA_PATH).json
@echo "Software Metadata Updated!"
# =========================================================
# Release
# =========================================================
pre-rel:
@test -n "$(RELEASE_DIR)"
@mkdir -p "$(RELEASE_DIR)"
@find "$(RELEASE_DIR)" -mindepth 1 -delete
# =========================================================
# Initialize
# =========================================================
go-ini:
@test -f go.mod || go mod init $(GO_MODULE)
go-tid:
go mod tidy
go-stp: \
go-ini \
go-tid
# =========================================================
# Build Group
# =========================================================
go-bld: \
pre-rel \
go-tid \
bld-lin-amd \
bld-lin-arm \
bld-win-amd \
bld-win-arm \
bld-mac-amd \
bld-mac-arm
go-bld-lin: \
pre-rel \
go-tid \
bld-lin-amd \
bld-lin-arm
go-bld-win: \
pre-rel \
go-tid \
bld-win-amd \
bld-win-arm
go-bld-mac: \
pre-rel \
go-tid \
bld-mac-amd \
bld-mac-arm
# =========================================================
# Build Target
# =========================================================
# Linux AMD64
bld-lin-amd:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build \
-trimpath \
-buildvcs=false \
-ldflags="-s -w" \
-o $(RELEASE_DIR)/$(SOFTWARE_LOWER)-v$(SOFTWARE_VERSION)-linux-amd64 \
$(SOURCE_DIR)
# Linux ARM64
bld-lin-arm:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 \
go build \
-trimpath \
-buildvcs=false \
-ldflags="-s -w" \
-o $(RELEASE_DIR)/$(SOFTWARE_LOWER)-v$(SOFTWARE_VERSION)-linux-arm64 \
$(SOURCE_DIR)
# Windows AMD64
bld-win-amd:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 \
go build \
-trimpath \
-buildvcs=false \
-ldflags="-s -w" \
-o $(RELEASE_DIR)/$(SOFTWARE_LOWER)-v$(SOFTWARE_VERSION)-windows-amd64.exe \
$(SOURCE_DIR)
# Windows ARM64
bld-win-arm:
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 \
go build \
-trimpath \
-buildvcs=false \
-ldflags="-s -w" \
-o $(RELEASE_DIR)/$(SOFTWARE_LOWER)-v$(SOFTWARE_VERSION)-windows-arm64.exe \
$(SOURCE_DIR)
# macOS AMD64
bld-mac-amd:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 \
go build \
-trimpath \
-buildvcs=false \
-ldflags="-s -w" \
-o $(RELEASE_DIR)/$(SOFTWARE_LOWER)-v$(SOFTWARE_VERSION)-macos-amd64 \
$(SOURCE_DIR)
# macOS ARM64
bld-mac-arm:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 \
go build \
-trimpath \
-buildvcs=false \
-ldflags="-s -w" \
-o $(RELEASE_DIR)/$(SOFTWARE_LOWER)-v$(SOFTWARE_VERSION)-macos-arm64 \
$(SOURCE_DIR)

236
README.md
View File

@ -0,0 +1,236 @@
# Go CLI Framework
## Overview
This document describes the CLI source tree represented by the project-root placeholder `source`. The structure separates shared data resources, framework-owned foundations, software-specific extensions, runtime composition, and project-level files.
## Architecture
### Data
The `data` directory provides the common resource system for framework-owned and software-owned embedded data, using a central cabinet, data-specific ledgers, and resource handlers to register and resolve resources through a controlled and lightweight access path.
- `data` — provides the common resource system for framework-owned and software-owned embedded data, using a central cabinet, data-specific ledgers, and resource handlers to register and resolve resources through a controlled and lightweight access path.
- `cabinet` — serves as the common coordination point for framework-owned and software-owned data ledgers, determining which ledger is responsible for a requested resource.
- `cabinet.go` — implements the cabinet that coordinates registration and access across the framework and software data ledgers.
- `framework` — contains the data resources owned and maintained by the framework developer.
- `ledger` — acts as the registrar for framework-owned resources and identifies the handler responsible for each resource.
- `ledger.go` — implements the framework-owned resource ledger and its resource registration and resolution.
- `metadata` — contains framework-owned metadata resources.
- `handler.go` — provides the resource-specific logic for accessing and parsing the embedded framework metadata when requested.
- `resource.json` — contains the embedded framework metadata resource.
- `software` — contains the data resources owned and maintained by the software developer.
- `ledger` — acts as the registrar for software-owned resources and identifies the handler responsible for each resource.
- `ledger.go` — implements the software-owned resource ledger and its resource registration and resolution.
- `metadata` — contains software-owned metadata resources.
- `handler.go` — provides the resource-specific logic for accessing and parsing the embedded software metadata when requested.
- `resource.json` — contains the embedded software metadata resource.
### Essential
The `essential` directory provides the framework-owned foundation used by software built on the framework, including framework interactions, internal services, and reusable services exposed to the software layer.
- `essential` — provides the framework-owned foundation used by software built on the framework, including framework interactions, internal services, and reusable services exposed to the software layer.
- `exchange` — serves as the registrar for framework-owned interactions, allowing framework services to register their interactive, imperative, and directive logic for later composition by the runtime.
- `directive` — contains the framework-owned directive interaction path.
- `directive.go` — implements framework-owned directive interaction handling.
- `imperative` — contains the framework-owned imperative interaction path.
- `imperative.go` — implements framework-owned imperative interaction handling.
- `interactive` — contains the framework-owned interactive interaction path.
- `interactive.go` — implements framework-owned interactive interaction handling.
- `router` — organizes the routing of framework-owned interactions to their appropriate interaction handling path.
- `router.go` — implements the framework-owned interaction routing.
- `hidden` — contains internal framework services that may be used within the essential layer but are not permitted to be called from the software layer, regardless of whether their functions are exported.
- `service` — contains internal framework services available to the framework.
- `management` — provides services for managing the lifecycle of the compiled binary.
- `clean` — provides the compiled binary cleanup service.
- `clean.go` — implements the compiled binary cleanup service.
- `install` — provides the compiled binary installation service.
- `install.go` — implements the compiled binary installation service.
- `uninstall` — provides the compiled binary uninstallation service.
- `uninstall.go` — implements the compiled binary uninstallation service.
- `update` — provides the compiled binary update service.
- `update.go` — implements the compiled binary update service.
- `worker` — provides the automation layer for the compiled binary while keeping its automation configuration outside the binary.
- `clock` — provides the clock syncronization service.
- `clock.go` — implements the clock syncronization service.
- `manager` — manages the workers responsible for executing automation.
- `manager.go` — implements worker management.
- `visible` — contains framework services that the software layer is permitted to call, providing reusable abstractions over framework capabilities.
- `service` — contains reusable framework services available to the software layer.
- `helper` — contains reusable helper services for common software needs.
- `cipher` — provides reusable encryption and decryption functionality.
- `cipher.go` — implements cipher functionality.
- `codec` — provides reusable encoding and decoding functionality.
- `codec.go` — implements codec functionality.
- `datetime` — provides reusable date and time utilities.
- `datetime.go` — implements date and time utilities.
- `filesystem` — provides reusable filesystem utilities.
- `filesystem.go` — implements filesystem utilities.
- `hash` — provides reusable hashing functionality.
- `hash.go` — implements hashing functionality.
- `key` — provides reusable key-generation functionality.
- `key.go` — implements key generation functionality.
- `log` — provides reusable logging utilities.
- `log.go` — implements logging utilities.
- `marker` — provides generalized identifier-generation functionality for uses that require generated markers or identifiers.
- `marker.go` — implements marker generation functionality.
- `progress` — provides reusable progress tracking utilities.
- `progress.go` — implements progress utilities.
- `retriever` — provides a unified interface for accessing both framework-owned and software-owned data.
- `retriever.go` — implements the unified data retrieval interface.
- `status` — provides reusable status utilities.
- `status.go` — implements status utilities.
### Operational
The `operational` directory contains the software-specific implementation and interaction components maintained by the software developer within the architecture provided by the framework.
- `operational` — contains the software-specific implementation and interaction components maintained by the software developer within the architecture provided by the framework.
- `exchange` — serves as the registrar for software-specific interactions, allowing software services to register their interactive, imperative, and directive logic for composition by the runtime.
- `directive` — contains the software-specific directive interaction path.
- `directive.go` — implements software-specific directive interaction handling.
- `imperative` — contains the software-specific imperative interaction path.
- `imperative.go` — implements software-specific imperative interaction handling.
- `interactive` — contains the software-specific interactive interaction path.
- `interactive.go` — implements software-specific interactive interaction handling.
- `router` — organizes the routing of software-specific interactions to their appropriate interaction handling path.
- `router.go` — implements the software-specific interaction routing.
- `mechanism` — contains the software-specific mechanisms through which application services and their features are implemented.
- `service` — serves as the container for software-specific services.
- `service` — placeholder for a software-specific service that is replaced with the actual service name.
- `feature` — contains the features provided by the software-specific service.
- `function.go` — implements a feature of the software-specific service.
### Run
The `run` directory provides the stable runtime entry and interaction composition layer for the compiled application.
- `run` — provides the stable runtime entry and interaction composition layer for the compiled application.
- `exchange` — combines the registered framework-owned and software-owned interactions into the unified interaction structure used by the running application.
- `directive` — receives and processes runtime directive interactions.
- `directive.go` — implements runtime directive interaction handling.
- `imperative` — receives and processes runtime imperative interactions.
- `imperative.go` — implements runtime imperative interaction handling.
- `interactive` — receives and processes runtime interactive interactions.
- `interactive.go` — implements runtime interactive interaction handling.
- `router` — routes incoming runtime interactions to the appropriate framework or software interaction path.
- `router.go` — implements runtime interaction routing.
- `main` — provides the executable entry point that initializes the required packages and starts the application without directly defining its menus, commands, flags, or arguments.
- `main.go` — bootstraps the runtime and starts the compiled application.
## Project Files
The project root contains the following project-level files:
- `.gitignore` — defines files and directories that should be excluded from version control.
- `CHANGELOG.md` — records changes made to the framework across versions.
- `go.mod` — defines the Go module configuration and dependency context for the project.
- `LICENSE.md` — defines the licensing terms governing the framework.
- `Makefile` — provides build, update, and automation tasks for maintaining and operating the framework.
- `README.md` — provides documentation describing the framework and its usage.
## Source Tree
The following structure represents the CLI source tree:
source
├── data
│ ├── cabinet
│ │ └── cabinet.go
│ ├── framework
│ │ ├── ledger
│ │ │ └── ledger.go
│ │ └── metadata
│ │ ├── handler.go
│ │ └── resource.json
│ └── software
│ ├── ledger
│ │ └── ledger.go
│ └── metadata
│ ├── handler.go
│ └── resource.json
├── essential
│ ├── exchange
│ │ ├── directive
│ │ │ └── directive.go
│ │ ├── imperative
│ │ │ └── imperative.go
│ │ ├── interactive
│ │ │ └── interactive.go
│ │ └── router
│ │ └── router.go
│ ├── hidden
│ │ └── service
│ │ ├── management
│ │ │ ├── clean
│ │ │ │ └── clean.go
│ │ │ ├── install
│ │ │ │ └── install.go
│ │ │ ├── uninstall
│ │ │ │ └── uninstall.go
│ │ │ └── update
│ │ │ └── update.go
│ │ └── worker
│ │ ├── clock
│ │ │ └── clock.go
│ │ └── manager
│ │ └── manager.go
│ └── visible
│ └── service
│ └── helper
│ ├── cipher
│ │ └── cipher.go
│ ├── codec
│ │ └── codec.go
│ ├── datetime
│ │ └── datetime.go
│ ├── filesystem
│ │ └── filesystem.go
│ ├── hash
│ │ └── hash.go
│ ├── key
│ │ └── key.go
│ ├── log
│ │ └── log.go
│ ├── marker
│ │ └── marker.go
│ ├── progress
│ │ └── progress.go
│ ├── retriever
│ │ └── retriever.go
│ └── status
│ └── status.go
├── operational
│ ├── exchange
│ │ ├── directive
│ │ │ └── directive.go
│ │ ├── imperative
│ │ │ └── imperative.go
│ │ ├── interactive
│ │ │ └── interactive.go
│ │ └── router
│ │ └── router.go
│ └── mechanism
│ └── service
│ └── service
│ └── feature
│ └── function.go
├── run
│ ├── exchange
│ │ ├── directive
│ │ │ └── directive.go
│ │ ├── imperative
│ │ │ └── imperative.go
│ │ ├── interactive
│ │ │ └── interactive.go
│ │ └── router
│ │ └── router.go
│ └── main
│ └── main.go
├── .gitignore
├── CHANGELOG.md
├── go.mod
├── LICENSE.md
├── Makefile
└── README.md

3
go.mod
View File

@ -0,0 +1,3 @@
module go/module
go 1.26.4