clee 0.4.2
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.
- checksums.yaml +7 -0
- data/LICENSE.md +90 -0
- data/README.md +280 -0
- data/Rakefile +448 -0
- data/TODO.md +1 -0
- data/bin/clee +55 -0
- data/clee.gemspec +40 -0
- data/docs/sunwukong.md +38 -0
- data/lib/clee/_lib.rb +75 -0
- data/lib/clee.rb +623 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 697ca9e38d2b574e981e199d00913d1ae7846b0fa5346991b334f712e42b08ff
|
4
|
+
data.tar.gz: b318d0c05114ea6be8564afcd562616d7fcc8cf083381f42f3052919b92e17ab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cdd0d1cdaed8376a96b90a67a2c7f5b5cb0bc46dcc6e40607bcd8e17c8b7e94cc512d8085f5501c16a63b4ec7f6c2351b9fb8f8b885232c64ab4ddfead1483dd
|
7
|
+
data.tar.gz: 0a89a07e1c4aa241634626f5f9819f514a4b7c8192d64f3402b49ef5a548ee61c8a8a122ec389c662c6da85fd1219438ebe66d128f1f0b91d7d3f2f1390c7e8c
|
data/LICENSE.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# Komorebi License
|
2
|
+
|
3
|
+
Version 1.0.0
|
4
|
+
|
5
|
+
## Acceptance
|
6
|
+
|
7
|
+
In order to get any license under these terms, you must agree to them as both
|
8
|
+
strict obligations and conditions to all your licenses.
|
9
|
+
|
10
|
+
## Copyright License
|
11
|
+
|
12
|
+
The licensor grants you a copyright license for the software to do everything
|
13
|
+
you might do with the software that would otherwise infringe the licensor's
|
14
|
+
copyright in it for any permitted purpose. However, you may only make changes
|
15
|
+
according to the [Changes License](#changes-license), and you may not
|
16
|
+
distribute the software or new works based on the software.
|
17
|
+
|
18
|
+
## Changes License
|
19
|
+
|
20
|
+
The licensor grants you an additional copyright license to make changes for any
|
21
|
+
permitted purpose.
|
22
|
+
|
23
|
+
## Patent License
|
24
|
+
|
25
|
+
The licensor grants you a patent license for the software that covers patent
|
26
|
+
claims the licensor can license, or becomes able to license, that you would
|
27
|
+
infringe by using the software.
|
28
|
+
|
29
|
+
## Personal Uses
|
30
|
+
|
31
|
+
Personal use for research, experiment, and testing for the benefit of public
|
32
|
+
knowledge, personal study, private entertainment, hobby projects, amateur
|
33
|
+
pursuits, or religious observance, without any anticipated commercial
|
34
|
+
application, is use for a permitted purpose.
|
35
|
+
|
36
|
+
## Fair Use
|
37
|
+
|
38
|
+
You may have "fair use" rights for the software under the law. These terms do
|
39
|
+
not limit them.
|
40
|
+
|
41
|
+
## No Other Rights
|
42
|
+
|
43
|
+
These terms do not allow you to sublicense or transfer any of your licenses to
|
44
|
+
anyone else, or prevent the licensor from granting licenses to anyone else.
|
45
|
+
These terms do not imply any other licenses.
|
46
|
+
|
47
|
+
## Patent Defense
|
48
|
+
|
49
|
+
If you make any written claim that the software infringes or contributes to
|
50
|
+
infringement of any patent, your patent license for the software granted under
|
51
|
+
these terms ends immediately. If your company makes such a claim, your patent
|
52
|
+
license ends immediately for work on behalf of your company.
|
53
|
+
|
54
|
+
## Violations
|
55
|
+
|
56
|
+
The first time you are notified in writing that you have violated any of these
|
57
|
+
terms, or done anything with the software not covered by your licenses, your
|
58
|
+
licenses can nonetheless continue if you come into full compliance with these
|
59
|
+
terms, and take practical steps to correct past violations, within 32 days of
|
60
|
+
receiving notice. Otherwise, all your licenses end immediately.
|
61
|
+
|
62
|
+
## No Liability
|
63
|
+
|
64
|
+
***As far as the law allows, the software comes as is, without any warranty or
|
65
|
+
condition, and the licensor will not be liable to you for any damages arising
|
66
|
+
out of these terms or the use or nature of the software, under any kind of
|
67
|
+
legal claim.***
|
68
|
+
|
69
|
+
## Definitions
|
70
|
+
|
71
|
+
The **licensor** is the individual or entity offering these terms, and the
|
72
|
+
**software** is the software the licensor makes available under these terms.
|
73
|
+
|
74
|
+
**You** refers to the individual or entity agreeing to these terms.
|
75
|
+
|
76
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of
|
77
|
+
organization that you work for, plus all organizations that have control over,
|
78
|
+
are under the control of, or are under common control with that organization.
|
79
|
+
**Control** means ownership of substantially all the assets of an entity, or
|
80
|
+
the power to direct its management and policies by vote, contract, or
|
81
|
+
otherwise. Control can be direct or indirect.
|
82
|
+
|
83
|
+
**Your licenses** are all the licenses granted to you for the software under
|
84
|
+
these terms.
|
85
|
+
|
86
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
87
|
+
|
88
|
+
## References
|
89
|
+
|
90
|
+
https://github.com/ahoward/komorebi-license
|
data/README.md
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
NAME
|
2
|
+
----
|
3
|
+
`clee`
|
4
|
+
|
5
|
+
TL;DR;
|
6
|
+
--------
|
7
|
+
`clee` is a tiny, 0 dependency, DSL for building über clean CLIs in Ruby
|
8
|
+
|
9
|
+
INSTALL
|
10
|
+
-------
|
11
|
+
```sh
|
12
|
+
gem install clee
|
13
|
+
```
|
14
|
+
|
15
|
+
URI
|
16
|
+
---
|
17
|
+
http://github.com/ahoward/clee
|
18
|
+
|
19
|
+
ABOUT
|
20
|
+
-----
|
21
|
+
|
22
|
+
`clee` is a minimalist version of `main` (https://github.com/ahoward/main), a
|
23
|
+
command line DSL i wrote almost 15 years ago, that has seen over [4 million
|
24
|
+
downloads](https://drawohara.io/rubygems/)
|
25
|
+
|
26
|
+
> then why should i use `clee` instead of `main` ?
|
27
|
+
|
28
|
+
* `clee` has 0 dependencies beyond ruby itself
|
29
|
+
|
30
|
+
* `clee` is very very small
|
31
|
+
```sh
|
32
|
+
drawohara@drawohara.dev:ahoward #=> loc clee/lib
|
33
|
+
|
34
|
+
clee/lib/clee.rb: 478
|
35
|
+
===
|
36
|
+
@loc: 478
|
37
|
+
|
38
|
+
|
39
|
+
drawohara@drawohara.dev:ahoward #=> loc main/lib
|
40
|
+
|
41
|
+
main/lib/main/cast.rb: 139
|
42
|
+
main/lib/main/daemon.rb: 395
|
43
|
+
main/lib/main/dsl.rb: 65
|
44
|
+
main/lib/main/factories.rb: 24
|
45
|
+
main/lib/main/getoptlong.rb: 245
|
46
|
+
main/lib/main/logger.rb: 43
|
47
|
+
main/lib/main/mode.rb: 41
|
48
|
+
main/lib/main/parameter.rb: 589
|
49
|
+
main/lib/main/program/class_methods.rb: 362
|
50
|
+
main/lib/main/program/instance_methods.rb: 274
|
51
|
+
main/lib/main/program.rb: 6
|
52
|
+
main/lib/main/softspoken.rb: 12
|
53
|
+
main/lib/main/stdext.rb: 34
|
54
|
+
main/lib/main/test.rb: 69
|
55
|
+
main/lib/main/usage.rb: 159
|
56
|
+
main/lib/main/util.rb: 96
|
57
|
+
main/lib/main.rb: 70
|
58
|
+
===
|
59
|
+
@loc: 2623
|
60
|
+
```
|
61
|
+
|
62
|
+
* you can use this to decide which to use:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
case
|
66
|
+
when wants?(:simple, :tiny, :scripting)
|
67
|
+
:clee
|
68
|
+
|
69
|
+
when wants?(:powerful, :testable, :complete, :mature)
|
70
|
+
:main
|
71
|
+
|
72
|
+
else
|
73
|
+
[:clee, :main].sort_by{ rand }.first
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
API
|
78
|
+
---
|
79
|
+
|
80
|
+
##### `clee`'s api is very simple. it has every feature you need, and none that you
|
81
|
+
don't, including:
|
82
|
+
|
83
|
+
- auto generated help messages
|
84
|
+
- support for `my_clee --help` and `my_clee help` to 'just work'
|
85
|
+
- support for modifying help/usage messages simply
|
86
|
+
- sane exit codes
|
87
|
+
- support for --options, env=val pairs, etc
|
88
|
+
- argv parsing
|
89
|
+
- fancy color'd logging
|
90
|
+
- modes, and sub-modes
|
91
|
+
|
92
|
+
##### the smallest clee script looks like this
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
require 'clee'
|
96
|
+
|
97
|
+
clee do
|
98
|
+
run do
|
99
|
+
p 42
|
100
|
+
end
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
##### you can name your scripts
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
require 'clee'
|
108
|
+
|
109
|
+
clee do
|
110
|
+
run do
|
111
|
+
help! #=> this will print a default usage message that will include 'my_clee'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
```
|
115
|
+
|
116
|
+
##### you can alter the default tldr, and help messages
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
require 'clee'
|
120
|
+
|
121
|
+
clee do
|
122
|
+
tldr <<~____
|
123
|
+
avoid using the default 'tldr'
|
124
|
+
____
|
125
|
+
end
|
126
|
+
```
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
require 'clee'
|
130
|
+
|
131
|
+
clee do
|
132
|
+
help <<~____
|
133
|
+
NAME
|
134
|
+
my_clee
|
135
|
+
|
136
|
+
USAGE
|
137
|
+
fully custom help...
|
138
|
+
____
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
##### specifying params is trivial
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
require 'clee'
|
146
|
+
|
147
|
+
clee do
|
148
|
+
# support `my_clee --verbose` and -v
|
149
|
+
#
|
150
|
+
option :verbose, :v
|
151
|
+
|
152
|
+
# support `my_clee --path=./lib`
|
153
|
+
#
|
154
|
+
option :path, value: :required
|
155
|
+
|
156
|
+
# support `my_clee API_KEY=123` *and* `API_KEY=123 my_clee`
|
157
|
+
#
|
158
|
+
env :API_KEY
|
159
|
+
|
160
|
+
# support `my_clee --foo=42` *and* `my_clee foo=42` *and* `foo=42 my_clee` syntax
|
161
|
+
#
|
162
|
+
param :foo, value: 'required'
|
163
|
+
|
164
|
+
# the interface and help messages work the same way for all the above
|
165
|
+
#
|
166
|
+
def run
|
167
|
+
if @options.has_key?(:verbose)
|
168
|
+
@verbose = true
|
169
|
+
end
|
170
|
+
|
171
|
+
@path = @options.fetch(:path)
|
172
|
+
|
173
|
+
@api_key = @env.fetch(:API_KEY)
|
174
|
+
|
175
|
+
@foo = @parms.fetch(:foo)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
```
|
179
|
+
|
180
|
+
##### modes, and sub-modes, are supported
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
require 'clee'
|
184
|
+
|
185
|
+
clee :my_clee do
|
186
|
+
run :foo do
|
187
|
+
p 42
|
188
|
+
end
|
189
|
+
|
190
|
+
run :foo, :bar do
|
191
|
+
p 42.0
|
192
|
+
end
|
193
|
+
|
194
|
+
run do
|
195
|
+
p 42.42
|
196
|
+
end
|
197
|
+
end
|
198
|
+
```
|
199
|
+
|
200
|
+
##### assuming you saved the above as `my_clee`, you could then do
|
201
|
+
```sh
|
202
|
+
~> my_clee foo #=> 42
|
203
|
+
~> my_clee foo bar #=> 42.0
|
204
|
+
~> my_clee #=> 42.42
|
205
|
+
```
|
206
|
+
|
207
|
+
##### `clee` scripts have a sweet dependency-less colored logger that understands what a #tty really is...
|
208
|
+
```ruby
|
209
|
+
require 'clee'
|
210
|
+
|
211
|
+
clee do
|
212
|
+
def run
|
213
|
+
log 'hai!'
|
214
|
+
log 'hai!', level: :warning
|
215
|
+
log 'blue', color: :blue
|
216
|
+
end
|
217
|
+
end
|
218
|
+
```
|
219
|
+
|
220
|
+
##### `clee` ships with a lil code-gen-thang
|
221
|
+
```sh
|
222
|
+
~> clee new my_clee > my_clee
|
223
|
+
~> chmod 755 my_clee
|
224
|
+
~> ./my_clee
|
225
|
+
```
|
226
|
+
|
227
|
+
i could write more docs but, they would then outnumber the LOC of the library
|
228
|
+
so:
|
229
|
+
|
230
|
+
1. see [./lib/clee.rb](./lib/clee.rb)
|
231
|
+
2. if that still doesn't float your boat install `ima`, a universal
|
232
|
+
command-line filter built on `clee`, that brings AI to your CLI and do
|
233
|
+
something like this
|
234
|
+
|
235
|
+
```sh
|
236
|
+
~> gem install clee ima
|
237
|
+
~> ima explain clee to me --context=$(gem which clee)
|
238
|
+
```
|
239
|
+
|
240
|
+
which might produce something like this ->
|
241
|
+
|
242
|
+
---
|
243
|
+
|
244
|
+
Clee is a Ruby library that provides a simple way to create command-line interfaces (CLI) for Ruby applications. It allows developers to define commands, options, and parameters for their application, and handles the parsing and execution of these commands.
|
245
|
+
|
246
|
+
The core features of Clee include:
|
247
|
+
|
248
|
+
* Command definition: Clee allows developers to define commands and their associated options and parameters.
|
249
|
+
* Option parsing: Clee can parse command-line options and parameters, and provides a simple way to define and handle these options.
|
250
|
+
* Parameter handling: Clee provides a way to handle command-line parameters, including required and optional parameters.
|
251
|
+
* Help generation: Clee can generate help text for commands and options, making it easy to provide documentation for users.
|
252
|
+
* Logging: Clee provides a logging mechanism that allows developers to log messages at different levels (e.g. debug, info, warning, error).
|
253
|
+
|
254
|
+
Clee is designed to be flexible and customizable, making it easy to integrate into existing Ruby applications. It also provides a number of features that make it easy to use, including automatic help generation and logging.
|
255
|
+
|
256
|
+
Some of the key concepts in Clee include:
|
257
|
+
|
258
|
+
* Commands: These are the top-level actions that a user can perform with the application.
|
259
|
+
* Options: These are the flags or switches that can be used to modify the behavior of a command.
|
260
|
+
* Parameters: These are the values that are passed to a command or option.
|
261
|
+
* Modes: These are alternative behaviors that a command can exhibit, depending on the options or parameters passed to it.
|
262
|
+
|
263
|
+
Overall, Clee is a powerful and flexible library that makes it easy to create command-line interfaces for Ruby applications. Its simple and intuitive API makes it easy to use, even for developers who are new to CLI development.
|
264
|
+
|
265
|
+
---
|
266
|
+
|
267
|
+
SING IT 🎵
|
268
|
+
----------
|
269
|
+
* **DOCS are dead, long live AI!**
|
270
|
+
* **UIs are dead, long live CLIS!**
|
271
|
+
|
272
|
+
FINALLY
|
273
|
+
-------
|
274
|
+
> why `clee`? that is honestly such a stupid name...
|
275
|
+
|
276
|
+
a good friend used to pronounce 'cli' as 'clee'. it stuck. i like it.
|
277
|
+
|
278
|
+
> i still need you write more docs for this free code
|
279
|
+
|
280
|
+
[c'mon in!](https://github.com/ahoward/clee/pulls)
|