kscript 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +113 -110
  3. data/lib/kscript/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa60e97dd2e5ebd0282945488335f81226666cc547f74608eb5b6d04370eec69
4
- data.tar.gz: 628577d54846ee750cf65e648bb13bce7c286182b49ef52813edb551b182a6f2
3
+ metadata.gz: 7c190f7d80e71baae5ec95db4f903cdc3ef98ea7403d5025eb9fcda0c4be18cc
4
+ data.tar.gz: f3150fac2025ac947c4e24b0dda29dee0e08f8cf4b2528322a64cfd6296f8e4b
5
5
  SHA512:
6
- metadata.gz: 79c677939e03109beac01c935773433218d95b663f7a4fea56980d3e6dbfc652eaadec7ed37ce1da38e77089cd6ff7524631e46a7dda71744e3868d8badf1734
7
- data.tar.gz: f29744a4e376a0476f91ee3a5788cd713f7a5c333114a3e4ef3616f5b3cb45783cceaca02b5798b2bf88c3038a28c50fe168d9e08c4700c31a5c3fd48376687c
6
+ metadata.gz: 2b522f1d8c390648132e3419e7ad186aa6acb4fdec572f37428f0697a076bde0f330bf0f035c08b833f60e5fbd31424b36bd2c3830973f72051b9aad9553e2b0
7
+ data.tar.gz: c3428e2286edec3f3a5a75208c37803660fb7a0f47047e5c6e122d7f4c547dfc64a046cada3ad8a1aafbfaeccb6374bdcd3bfbf2e749bf7ffe453396f59be645
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # kscript
2
+
2
3
  ```
3
4
  ______ _____ _____
4
5
  ___ /________________________(_)_________ /_
@@ -8,20 +9,32 @@ _ ,< _(__ )/ /__ _ / _ / __ /_/ / /_
8
9
  /_/
9
10
  ```
10
11
 
11
- A collection of Ruby utility scripts for various system administration and development tasks.
12
+ [![Gem Version](https://img.shields.io/gem/v/kscript?style=flat-square)](https://rubygems.org/gems/kscript)
13
+ [![CI Status](https://github.com/kevin197011/kscript/actions/workflows/gem-push.yml/badge.svg?branch=main)](https://github.com/kevin197011/kscript/actions/workflows/gem-push.yml)
14
+
15
+ > Ruby CLI 工具集,专为系统运维、开发自动化、网络与项目管理场景设计。支持插件化、极致美化输出、自动补全、结构化日志、CI/CD 自动发布等现代特性。
16
+
17
+ ---
12
18
 
13
- [![Gem Version](https://img.shields.io/gem/v/kscript)](https://rubygems.org/gems/kscript)
14
- [![Ruby](https://github.com/kevin197011/kscript/actions/workflows/gem-push.yml/badge.svg)](https://github.com/kevin197011/kscript/actions/workflows/gem-push.yml)
19
+ ## ✨ 特性亮点
20
+ - **统一 CLI 框架**:所有命令一键调用,美化输出
21
+ - **插件化架构**:业务命令即插件,易扩展、易维护
22
+ - **极致美化**:ASCII banner、彩色分组、对齐、分隔线,极客体验
23
+ - **人性化/结构化日志双模式**:`--log`/`--log-level` 切换,支持 JSON/终端友好输出
24
+ - **自动补全**:zsh/bash 补全脚本自动部署,命令一键补全
25
+ - **参数健壮**:所有插件兼容多余参数,支持全局参数过滤
26
+ - **CI/CD 自动发布**:GitHub Actions 自动构建并推送 RubyGem
27
+ - **多平台支持**:macOS、Linux、Windows(部分工具)
15
28
 
16
- ## Installation
29
+ ---
17
30
 
18
- ### Gem install (recommended)
31
+ ## 🚀 安装
19
32
 
20
33
  ```bash
21
34
  gem install kscript
22
35
  ```
23
36
 
24
- Or from local source:
37
+ 或源码安装:
25
38
 
26
39
  ```bash
27
40
  git clone https://github.com/kevin197011/kscript.git
@@ -30,140 +43,130 @@ gem build kscript.gemspec
30
43
  gem install ./kscript-*.gem
31
44
  ```
32
45
 
33
- ### Bundler (for development)
34
-
35
- ```bash
36
- git clone https://github.com/kevin197011/kscript.git
37
- cd kscript
38
- bundle install
39
- ```
40
-
41
- ## Usage
46
+ ---
42
47
 
43
- Most scripts can be executed directly via command line after gem install:
48
+ ## 🛠️ 快速上手
44
49
 
50
+ ### 查看所有命令
45
51
  ```bash
46
- kscript SCRIPT_NAME [args]
52
+ kscript list
47
53
  ```
48
54
 
49
- Or, for legacy usage via curl:
50
-
55
+ ### 查看主命令帮助
51
56
  ```bash
52
- curl -sSL https://raw.githubusercontent.com/kevin197011/kscript/main/bin/SCRIPT_NAME.rb | ruby
57
+ kscript help
53
58
  ```
54
59
 
55
- ## Available Scripts
56
-
57
- ### System Tools
58
- - `mac-top-usage.rb` - Display top CPU and memory usage processes on macOS
59
- - `port-scanner.rb` - Multi-threaded port scanner
60
- - `mouse-simulator.rb` - Simulate mouse movement to prevent system idle
61
- - `source-cleaner.rb` - Clean up old source code versions
62
- - `ffmpeg-installer.rb` - FFmpeg installation script for Linux systems
63
-
64
- ### Network Tools
65
- - `ip-api.rb` - Query IP geolocation information (supports auto-detecting public IP)
66
- - `apnic-ip-range.rb` - Fetch IP ranges from APNIC database
67
- - `wireguard-acl.rb` - Configure WireGuard firewall access control
68
- - `wireguard-password.rb` - Generate WireGuard password hashes
69
-
70
- ### Development Tools
71
- - `shell-helper.rb` - Quick shell command reference tool
72
- - `rename.rb` - Batch rename files using regular expressions
73
- - `jenkins-job-manager.rb` - Manage Jenkins jobs (export/import)
74
- - `kibana-utils.rb` - Kibana management utilities
75
-
76
- ### Windows Specific
77
- - `windows-font-enhancer.rb` - Enhance Windows font rendering (macOS-like)
78
-
79
- ### Infrastructure Tools
80
- - `elastic-cert-fingerprint.rb` - Generate Elasticsearch certificate fingerprints
81
- - `lvm-mounter.rb` - LVM volume creation and mounting utility
82
-
83
- ## Examples
84
-
85
- 1. Query IP geolocation:
60
+ ### 查看版本
86
61
  ```bash
87
- # Query specific IP
88
- curl -sSL https://raw.githubusercontent.com/kevin197011/kscript/main/bin/ip-api.rb | ruby 8.8.8.8
89
-
90
- # Query your public IP
91
- curl -sSL https://raw.githubusercontent.com/kevin197011/kscript/main/bin/ip-api.rb | ruby
62
+ kscript version
92
63
  ```
93
64
 
94
- 2. View system resource usage:
65
+ ### 执行插件命令
95
66
  ```bash
96
- curl -sSL https://raw.githubusercontent.com/kevin197011/kscript/main/bin/mac-top-usage.rb | ruby
67
+ kscript <command> [args...]
68
+ # 例如
69
+ kscript apnic CN
70
+ kscript portscan 192.168.1.1
71
+ kscript sh 'ls -l'
72
+ kscript projscan ~/projects
97
73
  ```
98
74
 
99
- 3. Scan ports:
75
+ ### 结构化日志模式
100
76
  ```bash
101
- curl -sSL https://raw.githubusercontent.com/kevin197011/kscript/main/bin/port-scanner.rb | ruby
77
+ kscript apnic CN --log
78
+ kscript portscan 192.168.1.1 --log-level=debug
102
79
  ```
103
80
 
104
- ## Dependencies
81
+ ---
82
+
83
+ ## 🧩 插件与命令一览
84
+
85
+ > 运行 `kscript list` 可分组美化展示所有插件命令
86
+
87
+ - **network**
88
+ - `apnic`:获取国家 IPv4 段
89
+ - `portscan`:端口扫描
90
+ - `ip`:IP 工具
91
+ - `wg_acl`:WireGuard 防火墙 ACL
92
+ - `wg_pass`:WireGuard 密码工具
93
+ - **project**
94
+ - `projscan`:扫描目录下所有 git 项目
95
+ - `cleaner`:源码多版本清理
96
+ - `rename`:批量重命名文件
97
+ - **system/macos**
98
+ - `syscheck`:macOS 系统健康检查
99
+ - `top`:macOS 资源占用排行
100
+ - `optimize`:macOS 性能优化
101
+ - `sh`:命令行速查/cheatsheet
102
+ - **media**
103
+ - `ffmpeg`:FFmpeg 安装与检测
104
+ - **elastic**
105
+ - `es_fingerprint`:Elasticsearch 证书指纹
106
+ - `kibana`:Kibana 空间/索引/用户/角色自动化
107
+ - **ci**
108
+ - `jenkins`:Jenkins Job 导入导出
109
+ - **其它**
110
+ - `usd`:美元汇率工具
111
+ - `lvm`:LVM 卷管理
112
+ - `windows_font_enhancer`:Windows 字体增强
113
+
114
+ ---
115
+
116
+ ## ⚡ Shell 自动补全
117
+
118
+ - **首次运行自动为 zsh/bash 部署补全脚本**,无需手动操作
119
+ - 补全脚本路径:
120
+ - zsh: `~/.zsh/completions/_kscript`
121
+ - bash: `~/.bash_completion.d/kscript`
122
+ - 手动生成:
123
+ ```bash
124
+ kscript completion zsh > ~/.zsh/completions/_kscript
125
+ kscript completion bash > ~/.bash_completion.d/kscript
126
+ ```
127
+
128
+ ---
129
+
130
+ ## ⚙️ 全局配置
131
+
132
+ 在 `~/.kscriptrc` (YAML) 配置全局参数:
105
133
 
106
- Required gems:
107
- ```ruby
108
- gem 'http'
109
- gem 'rubocop'
134
+ ```yaml
135
+ log_level: debug
110
136
  ```
111
137
 
112
- ## License
138
+ ---
113
139
 
114
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
140
+ ## 🧑‍💻 插件开发规范
141
+ - 插件文件统一放在 `lib/kscript/plugins/kk_xxx_utils.rb`
142
+ - 类名如 `KkApnicUtils`,自动注册为 `apnic` 命令
143
+ - 支持 `self.description`、`self.usage`、`self.arguments`、`self.group`、`self.author`
144
+ - 输出统一用 `logger.kinfo`/`logger.kerror`,支持结构化日志
145
+ - 兼容多余参数,避免 ArgumentError
115
146
 
116
- ## Contributing
147
+ ---
117
148
 
118
- 1. Fork it
119
- 2. Create your feature branch (`git checkout -b feature/my-new-feature`)
120
- 3. Commit your changes (`git commit -am 'Add some feature'`)
121
- 4. Push to the branch (`git push origin feature/my-new-feature`)
122
- 5. Create new Pull Request
149
+ ## 🚚 CI/CD 自动发布
123
150
 
124
- ## Unified CLI Usage
151
+ - `.github/workflows/gem-push.yml`:main 分支和 PR 自动构建、tag push 自动发布到 RubyGems
152
+ - 需在 GitHub secrets 配置 `RUBYGEMS_API_KEY`
153
+ - [CI 状态与历史](https://github.com/kevin197011/kscript/actions/workflows/gem-push.yml)
125
154
 
126
- After gem install, you can use the unified kk command:
155
+ ---
127
156
 
128
- ```bash
129
- kk <command> [args...]
157
+ ## 📄 许可证
130
158
 
131
- # List all available tools
132
- kk --help
159
+ MIT License. 详见 [LICENSE](LICENSE)。
133
160
 
134
- # Example: scan ports
135
- kk port-scanner 192.168.1.1
136
-
137
- # Example: check macOS system
138
- kk mac-sys-check
139
- ```
161
+ ---
140
162
 
141
- Each subcommand supports --help for its own usage.
163
+ ## 🤝 贡献
142
164
 
143
- ## Global Configuration
165
+ 1. Fork & PR
166
+ 2. 遵循输出与插件开发规范
167
+ 3. 保持文档与代码同步
144
168
 
145
- You can set global options for all kk tools in `~/.kscriptrc` (YAML format):
146
-
147
- ```yaml
148
- log_level: debug
149
- trace_id: my-global-trace
150
- ```
151
-
152
- - These settings will be used by default for all commands unless overridden by CLI options or environment variables.
153
-
154
- ## Shell Completion 自动补全
155
-
156
- kscript 现已支持 zsh 和 bash 的命令自动补全,且**安装后首次运行会自动为你部署补全脚本**,无需手动操作。
157
-
158
- - **zsh 补全脚本路径**:`~/.zsh/completions/_kscript`
159
- - **bash 补全脚本路径**:`~/.bash_completion.d/kscript`
160
-
161
- 如需手动重新生成补全脚本,可运行:
162
-
163
- ```bash
164
- kscript completion zsh > ~/.zsh/completions/_kscript
165
- kscript completion bash > ~/.bash_completion.d/kscript
166
- ```
169
+ ---
167
170
 
168
- > 每次升级或新增命令后,补全脚本也会自动更新。
171
+ 如需更多示例、插件开发指导或遇到问题,欢迎提 issue 或 PR!
169
172
 
@@ -6,5 +6,5 @@
6
6
  # https://opensource.org/licenses/MIT
7
7
 
8
8
  module Kscript
9
- VERSION = '0.1.0'
9
+ VERSION = '1.0.0'
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk