km is a lightweight operational script runner built with Perl modules.
- Single entrypoint CLI:
km - Convention-based modules: each
.pmis a runnable script module - Core-only dependencies (avoid external CPAN modules by default)
- Automation-friendly: non-interactive, stable outputs, standardized exit codes
List available modules:
perl bin/km listInstall directly from a GitHub repository:
cpanm https://github.com/kevin197011/km.gitAfter install, you should be able to run km as a command:
km list
km help ping
km install-nginx --dry-runBecause this project moved some modules from the legacy flat layout to lifecycle directories, old installed .pm files may remain on hosts after upgrade (cpanm/MakeMaker does not reliably remove moved/renamed files).
km will also attempt a best-effort auto-prune of legacy flat modules when it detects lifecycle-vs-legacy duplicates (requires write permission to the installed Perl library path).
You can prune legacy files safely:
km tool-prune-legacy # dry-run
km tool-prune-legacy --yes # delete (may require root)cpanm -l "$HOME/perl5" https://github.com/kevin197011/km.git
export PATH="$HOME/perl5/bin:$PATH"Show help:
perl bin/km help
perl bin/km help pingRun a module:
perl bin/km hello --name=kevin
perl bin/km ping --host=127.0.0.1 --port=22 --count=1 --timeout=1Modules live under lib/KM/Script/:
lib/KM/Script/Hello.pm # -> km hello
lib/KM/Script/Ping.pm # -> km ping
lib/KM/Script/Install/Docker.pm # -> km install-docker
lib/KM/Script/Install/Nginx.pm # -> km install-nginx
lib/KM/Script/Deploy/Example.pm # -> km deploy-example
lib/KM/Script/Install/Example.pm # -> km install-example
lib/KM/Script/Update/Example.pm # -> km update-example
lib/KM/Script/Remove/Example.pm # -> km remove-example
lib/KM/Script/Other/Example.pm # -> km other-example
lib/KM/Script/Tool/Example.pm # -> km tool-example
Lifecycle stages (recommended layout):
lib/KM/Script/
Install/
Deploy/
Update/
Remove/
Other/
Tool/
Mapping rules:
lib/KM/Script/Deploy/AppRelease.pm→KM::Script::Deploy::AppRelease→km deploy-app-releaselib/KM/Script/Install/Nginx.pm→KM::Script::Install::Nginx→km install-nginxlib/KM/Script/Other/Doctor.pm→KM::Script::Other::Doctor→km other-doctorlib/KM/Script/Tool/Doctor.pm→KM::Script::Tool::Doctor→km tool-doctor
Each module:
- MUST implement
runand return a numeric exit code (0means success) - SHOULD provide
our $DESCRIPTION,usage, andexamples - MUST use
use strict;anduse warnings;
0: success2: usage/argument error3: module not found4: module load/compile error5: module runtime error
ruby scripts/test.rb