argvise 0.0.8 → 0.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96b6f0c2b58c2c978c647f988896d96377fa798b5df00eb372d8f2c13de6d479
4
- data.tar.gz: ebdd6ef0219a35ab0c585f9310be93ac6f8a22b6376289002b8c414e4ffa6b4e
3
+ metadata.gz: 2d90fe07a2a4f58f550d26612903b467d83b99b1a0e0ae4ed00577e8e7459987
4
+ data.tar.gz: 444080af117dee382d702e6d3148d94733a90d94286187a55adda3744e37fb21
5
5
  SHA512:
6
- metadata.gz: 6124154af43827d0b5d65d5c086ecb0941daf7f5b56a35655072ee6ba75486340d0eede11aebeb29e95cf69540cd3932e41f0d498d578e68e8ea580abef9ece2
7
- data.tar.gz: 82a72a33658ea1e190a6f16f181e2d4a9f4c6bad414aa815307e4118a45d53624685809488e276ab84609509467b9fa7e7cda4001e89cfb3a428b073de6247a4
6
+ metadata.gz: ea1a7f17329319d8c172c092de516ebbaaf1440d4fafe4a12c3265f20e62e1169c34cc034c011bb84b1cb9feec1434c0eaccad3597d9361fc8b739e381b36d11
7
+ data.tar.gz: f7195c500e27b7cd429a6d23cbc95c76b1c32c468a22784503c491405cd5079190719ae4df76db9069d3dc54d091385c375bc0ae7984d6cf1f3e663e113d106d
data/.rubocop.yml CHANGED
@@ -1,2 +1,45 @@
1
+ # ln ~/.config/rubocop/config.yml .rubocop.yml
1
2
  AllCops:
2
3
  TargetRubyVersion: 3.1
4
+
5
+ Lint/MissingCopEnableDirective:
6
+ Enabled: false
7
+ Lint/RedundantCopDisableDirective:
8
+ Enabled: false
9
+ Lint/EmptyExpression:
10
+ # disabled => allow ()
11
+ Enabled: false
12
+
13
+ # https://docs.rubocop.org/rubocop/cops_style.html
14
+ Style/TrailingCommaInHashLiteral:
15
+ EnforcedStyleForMultiline: diff_comma
16
+ Style/TrailingCommaInArrayLiteral:
17
+ EnforcedStyleForMultiline: diff_comma
18
+ Style/Lambda:
19
+ EnforcedStyle: literal
20
+ Style/ModuleFunction:
21
+ # EnforcedStyle: extend_self
22
+ EnforcedStyle: module_function
23
+ Style/BlockDelimiters:
24
+ EnforcedStyle: braces_for_chaining
25
+ Style/Documentation:
26
+ Enabled: false
27
+ Style/ClassAndModuleChildren:
28
+ EnforcedStyle: compact
29
+
30
+ # https://docs.rubocop.org/rubocop/cops_metrics.html
31
+ Metrics/MethodLength:
32
+ Max: 15
33
+
34
+ # https://docs.rubocop.org/rubocop/cops_layout.html
35
+ Layout/CaseIndentation:
36
+ EnforcedStyle: end
37
+ IndentOneStep: true
38
+ Layout/MultilineMethodCallIndentation:
39
+ EnforcedStyle: indented
40
+
41
+
42
+ Naming/AsciiIdentifiers:
43
+ # AsciiConstants: false
44
+ Enabled: false
45
+
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --markup markdown
2
+ --title 'Argvise'
3
+ --protected
4
+ --no-private
data/docs/Readme.md CHANGED
@@ -8,6 +8,12 @@ A Ruby gem for converting hash structures into command-line argument arrays.
8
8
 
9
9
  > **Note:** This is *not* a command-line parser — quite the opposite. Argvise helps you **build** CLI commands programmatically.
10
10
 
11
+ ## API DOC
12
+
13
+ ![ClassDiagram](../misc/assets/svg/ClassDiagram.svg)
14
+
15
+ - Github Pages: <https://2moe.github.io/argvise-gem>
16
+
11
17
  ## Quick Start
12
18
 
13
19
  ```ruby
@@ -23,6 +29,9 @@ raw_cmd_hash = {
23
29
  cargo: (), b: (), r: true, target: "wasm32-wasip2"
24
30
  }
25
31
 
32
+ using Argvise::HashRefin
33
+ # OR: include Argvise::HashMixin
34
+
26
35
  raw_cmd_hash
27
36
  .to_argv
28
37
  # .to_argv({bsd_style: false, kebab_case_flags: true})
@@ -183,16 +192,57 @@ Argvise.build(raw_cmd_hash)
183
192
 
184
193
  ### Shortcut
185
194
 
195
+ #### Mixin
196
+
197
+ ```ruby
198
+ require 'argvise'
199
+
200
+ module A
201
+ module_function
202
+ include Argvise::HashMixin
203
+
204
+ def demo
205
+ { path: '/path/to/dir' }.to_argv.then { p it }
206
+ #=> ["--path", "/path/to/dir"]
207
+
208
+ { path: '/path/to/dir' }.to_argv_bsd.then { p it }
209
+ #=> ["-path", "/path/to/dir"]
210
+ end
211
+ end
212
+
213
+ A.demo
214
+ Hash.method_defined?(:to_argv) # => true
215
+ {}.respond_to?(:to_argv) #=> true
216
+ ```
217
+
218
+ #### Refinement
219
+
186
220
  ```ruby
187
- { v: true, dir: '/path/to/dir' }.to_argv
188
- # => ["-v", "--dir", "/path/to/dir"]
221
+ require 'argvise'
222
+ class A
223
+ using Argvise::HashRefin
224
+
225
+ def self.demo
226
+ { target: "wasm32-wasip2" }.to_argv.then { p it }
227
+ # => ["--target", "wasm32-wasip2"]
228
+
229
+ { target: "wasm32-wasip2" }.to_argv_bsd.then { p it }
230
+ # => ["-target", "wasm32-wasip2"]
231
+
232
+ {}.respond_to?(:to_argv).then { p it } #=> true
233
+ end
234
+ end
235
+
236
+ A.demo
237
+ Hash.method_defined?(:to_argv) # => false
238
+ {}.respond_to?(:to_argv) #=> false
189
239
  ```
190
240
 
191
241
  ### Configurable builder
192
242
 
193
243
  > Required
194
244
  >
195
- > - argvise: >= v0.0.6
245
+ > - argvise: >= v0.0.9
196
246
  > - ruby: >= v3.1.0
197
247
 
198
248
  ```ruby
@@ -225,6 +275,10 @@ raw_cmd
225
275
  #=> ["compiler", "build", "--pack_type", "tar+zstd", "--push", "-v", "-f", "p2", "--tag", "v0.0.1", "--tag", "beta", "--platform", "wasi/wasm", "--label", "maintainer=user", "--label", "description=Demo", "/path/to/dir"]
226
276
 
227
277
  p '----------------'
278
+
279
+ # argvise: >= v0.0.9
280
+ using Argvise::HashRefin
281
+
228
282
  p 'GNU-style + kebab-case-flags=true'
229
283
  # argvise: >= v0.0.6
230
284
  raw_cmd
@@ -235,15 +289,13 @@ raw_cmd
235
289
 
236
290
  p '----------------'
237
291
  p 'BSD-style + kebab-case-flags=true'
238
- # argvise: >= v0.0.4
292
+ # argvise: >= v0.0.9
239
293
  raw_cmd
240
- .then(&Argvise.new_proc)
241
- .with_bsd_style
242
- .with_kebab_case_flags
243
- .build
294
+ .to_argv_bsd
244
295
  .display
245
296
 
246
297
  #=> ["compiler", "build", "-pack-type", "tar+zstd", "-push", "-v", "-f", "p2", "-tag", "v0.0.1", "-tag", "beta", "-platform", "wasi/wasm", "-label", "maintainer=user", "-label", "description=Demo", "/path/to/dir"]
298
+ p '----------------'
247
299
  ```
248
300
 
249
301
  ## Data Type
@@ -302,15 +354,27 @@ raw_cmd
302
354
 
303
355
  - `{ cargo: () }` => `["cargo"]`
304
356
  - `{ cargo: nil, b: nil }` => `["cargo", "b"]`
305
- - `{ "-fv": nil }` => `["-fv"]`
357
+ - `{ "-fv": () }` => `["-fv"]`
306
358
 
307
359
  ## Changelog
308
360
 
309
361
  ### v0.0.6 (2025-11-05)
310
362
 
311
- Breaking Changes:
363
+ Breaking Change:
312
364
 
313
365
  - `cmd_hash |> hash_to_argv` => `cmd_hash.to_argv(opts)`
314
- - i.e.,
315
- - old: `{a: true}.then(&hash_to_argv)`
316
- - new: `{a: true}.to_argv`
366
+ - Previous: `{a: true}.then(&hash_to_argv)`
367
+ - Current: `{a: true}.to_argv`
368
+
369
+ ### v0.0.9 (2025-11-30)
370
+
371
+ - add refinements for Hash
372
+ - add `Hash#to_argv_bsd`
373
+
374
+ Breaking Change:
375
+ - Mitigated side effects introduced by monkey patching.
376
+ - Previous:
377
+ - Simply calling `require 'argvise'` was enough to import `Hash#to_argv`;
378
+ - no explicit `include` or `using` was required.
379
+ - Current:
380
+ - We must manually `include Argvise::HashMixin` or `using Argvise::HashRefin` to import `Hash#to_argv`.
data/lib/argvise/core.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  # ------------------
6
6
  # Converts hash to command array
7
7
  #
8
- # == Example
8
+ # @example
9
9
  #
10
10
  # { cargo: nil, b: nil, r: true, target: "wasm32-wasip2" }
11
11
  # .then(&Argvise.new_proc)
@@ -15,9 +15,9 @@
15
15
  #
16
16
  # #=> ["cargo", "b", "-r", "--target", "wasm32-wasip2"]
17
17
  #
18
- # == Conversion Rules:
18
+ # # Conversion Rules:
19
19
  #
20
- # === GNU Style:
20
+ # ## GNU Style:
21
21
  # - Boolean values:
22
22
  # - `{ verbose: true }` => ["--verbose"]
23
23
  # - `{ v: true }` => ["-v"]
@@ -32,7 +32,7 @@
32
32
  # - `{ L: { env: 'test' } }` => `["-L", "env=test"]`
33
33
  # - `{ label: { env: 'test' } }` => `["--label", "env=test"]`
34
34
  #
35
- # === BSD Style:
35
+ # ## BSD Style:
36
36
  # - Boolean values:
37
37
  # - `{ verbose: true }` => ["-verbose"]
38
38
  # - `{ v: true }` => ["-v"]
@@ -47,12 +47,12 @@
47
47
  # - `{ L: { env: 'test' } }` => `["-L", "env=test"]`
48
48
  # - `{ label: { env: 'test' } }` => `["-label", "env=test"]`
49
49
  #
50
- # === Common:
50
+ # ## Common:
51
51
  # - Raw values:
52
52
  # - `{ cargo: nil, b: nil}` => `["cargo", "b"]`
53
53
  # - `{ "-fv": nil}` => `["-fv"]`
54
54
  #
55
- # === About kebab_case_flags:
55
+ # ## About kebab_case_flags:
56
56
  # - `with_kebab_case_flags(true)`:
57
57
  # - `{enable_jit: true}` =>
58
58
  # - GNU-style: `["--enable-jit"]`
@@ -70,18 +70,17 @@ class Argvise
70
70
  class << self
71
71
  # Converts a hash into a command-line argument array
72
72
  #
73
- # == Example
73
+ # @example
74
74
  # require 'argvise'
75
75
  # cmd = { ruby: nil, r: "argvise", verbose: true, e: true, "puts Argvise::VERSION": nil }
76
76
  # opts = { bsd_style: false }
77
77
  # Argvise.build(cmd, opts:)
78
78
  #
79
- # == Params
80
- # - raw_cmd_hash [Hash] The hash to be converted (i.e., raw input data)
81
- # - opts [Hash] See also: [self.new]
79
+ # @param raw_cmd_hash [Hash] The hash to be converted (i.e., raw input data)
80
+ # @param opts [Hash]
81
+ # @see #initialize
82
82
  #
83
- # == Returns
84
- # [Array<String>] The generated array of command-line arguments
83
+ # @return [Array<String>] The generated array of command-line arguments
85
84
  def build(
86
85
  raw_cmd_hash,
87
86
  opts: nil
@@ -94,15 +93,16 @@ class Argvise
94
93
  #
95
94
  # Useful for transforming a hash of CLI arguments into a command array.
96
95
  #
97
- # == Example
96
+ # @example
98
97
  #
99
- # require 'argvise'
100
- # { ruby: nil, r: "argvise", e: true, "puts Argvise::VERSION": nil }
101
- # .then(&Argvise.new_proc)
102
- # .build
103
- # .then{system *_1}
98
+ # require 'argvise'
99
+ # { ruby: nil, r: "argvise", e: true, "puts Argvise::VERSION": nil }
100
+ # .then(&Argvise.new_proc)
101
+ # .build
102
+ # .then{system *_1}
104
103
  #
105
- # > See also: [self.new]
104
+ # @see #initialize
105
+ # @return [::Proc] `.call(raw_cmd_hash)` => self
106
106
  def new_proc
107
107
  ->(raw_cmd_hash) do
108
108
  new(raw_cmd_hash)
@@ -111,15 +111,16 @@ class Argvise
111
111
  # ----
112
112
  end
113
113
 
114
- # == Example
114
+ # @example
115
115
  #
116
116
  # require 'argvise'
117
117
  # cmd = { ruby: nil, r: "argvise", verbose: true, e: true, "puts Argvise::VERSION": nil }
118
118
  # opts = Argvise::DEFAULT_OPTS
119
119
  # Argvise.new(cmd, opts:).build.then{system *_1}
120
120
  #
121
- # == opts
122
- # [Hash]: { bsd_style: Boolean, kebab_case_flags: Boolean }
121
+ # @param opts [Hash]: { bsd_style: Boolean, kebab_case_flags: Boolean }
122
+ #
123
+ # ## opts
123
124
  #
124
125
  # - When `bsd_style` is set to `false`, the builder operates in **GNU-style mode**,
125
126
  # which typically uses hyphenated flags.
@@ -128,12 +129,11 @@ class Argvise
128
129
  # will be automatically converted to hyphens (`-`).
129
130
  # - For example, a flag like `--enable_jit` will be transformed into `--enable-jit`.
130
131
  #
131
- # When the value of a flag key is `nil`, the `kebab_case_flags` option has no effect
132
+ # When the value of a flag key is `nil`, the `kebab_case_flags` option has no effect.
132
133
  # — i.e., the key will not be transformed.
133
134
  #
134
135
  # For example, the input `{"a_b-c": nil}` will result in `["a_b-c"]`,
135
136
  # and **not** be automatically transformed into `["a-b-c"]`.
136
- #
137
137
  def initialize(
138
138
  raw_cmd_hash,
139
139
  opts: nil
@@ -145,16 +145,21 @@ class Argvise
145
145
  @kebab_case_flags = opts[:kebab_case_flags]
146
146
  end
147
147
 
148
+ # Default: true
149
+ # @return [self]
148
150
  def with_bsd_style(value = true) # rubocop:disable Style/OptionalBooleanParameter
149
151
  @bsd_style = value
150
152
  self
151
153
  end
152
154
 
155
+ # Default: true
156
+ # @return [self]
153
157
  def with_kebab_case_flags(value = true) # rubocop:disable Style/OptionalBooleanParameter
154
158
  @kebab_case_flags = value
155
159
  self
156
160
  end
157
161
 
162
+ # @return [Array<String>]
158
163
  def build
159
164
  # @raw_cmd_hash.each_pair.flat_map { |k, v| process_pair(k.to_s, v) }
160
165
  @raw_cmd_hash.each_with_object([]) do |(k, v), memo|
@@ -185,13 +190,13 @@ class Argvise
185
190
  # - short key, e.g., {verbose: true} => "-verbose"
186
191
  # - no long key
187
192
  #
188
- # @kebab_case_flags==true:
193
+ # kebab_case_flags==true:
189
194
  # - "_" => "-"
190
195
  # - e.g., {enable_jit: true} =>
191
196
  # - BSD-style: "-enable-jit"
192
197
  # - GNU-style: "--enable-jit"
193
198
  #
194
- # @kebab_case_flags==false:
199
+ # kebab_case_flags==false:
195
200
  # - e.g., {enable_jit: true} =>
196
201
  # - BSD-style: "-enable_jit"
197
202
  # - GNU-style: "--enable_jit"
@@ -216,21 +221,21 @@ class Argvise
216
221
  # Generates the corresponding argument array based on the value type
217
222
  def generate_args(flag, value)
218
223
  case value
219
- when true
220
- [flag]
221
- when Array
222
- expand_array(flag, value)
223
- when Hash
224
- expand_hash(flag, value)
225
- else
226
- # e.g., {tag: 'uuu'} => ["--tag", "uuu"]
227
- [flag, value.to_s]
224
+ when true
225
+ [flag]
226
+ when Array
227
+ expand_array(flag, value)
228
+ when Hash
229
+ expand_hash(flag, value)
230
+ else
231
+ # e.g., {tag: 'uuu'} => ["--tag", "uuu"]
232
+ [flag, value.to_s]
228
233
  end
229
234
  end
230
235
 
231
- # {tag: ["v1", "v2"]}
232
- # => (flag: "--tag", array: ['v1', 'v2'])
233
- # => ["--tag", "v1", "--tag", "v2"]
236
+ # {tag: ["v1", "v2"]}
237
+ # => (flag: "--tag", array: ['v1', 'v2'])
238
+ # => ["--tag", "v1", "--tag", "v2"]
234
239
  def expand_array(flag, array)
235
240
  # FP style: array.flat_map { |v| [flag, v.to_s] }
236
241
  array.each_with_object([]) do |v, memo|
@@ -241,9 +246,9 @@ class Argvise
241
246
 
242
247
  # Processes hash values (generates key=value format)
243
248
  #
244
- # {label: { env: "test", key: "value" }}
245
- # => (flag: "--label", hash)
246
- # => ["--label", "env=test", "--label", "key=value"]
249
+ # {label: { env: "test", key: "value" }}
250
+ # => (flag: "--label", hash)
251
+ # => ["--label", "env=test", "--label", "key=value"]
247
252
  def expand_hash(flag, hash)
248
253
  # hash.flat_map { |k, v| [flag, "#{k}=#{v}"] }
249
254
  hash.each_with_object([]) do |(k, v), memo|
@@ -253,30 +258,90 @@ class Argvise
253
258
  end
254
259
  end
255
260
 
256
- class ::Hash # rubocop:disable Style/Documentation
257
- # Converts a hash into command-line arguments
261
+ class Argvise
262
+ # The foundation of {HashRefin} and {HashMixin}
263
+ module HashExt
264
+ # Converts a hash map into GNU-style command-line arguments.
265
+ #
266
+ # @param opts [Hash, nil] See also `Argvise.new`
267
+ #
268
+ # @see Argvise#initialize
269
+ # @see to_argv_bsd
270
+ #
271
+ # @example Basic usage
272
+ #
273
+ # require 'argvise'
274
+ # using Argvise::HashRefin
275
+ #
276
+ # { v: true, path: '/path/to/dir' }.to_argv
277
+ # #=> ["-v", "--path", "/path/to/dir"]
278
+ #
279
+ #
280
+ # @example raw_cmd_hash.to_argv is equivalent to:
281
+ #
282
+ # raw_cmd_hash
283
+ # .then(&Argvise.new_proc)
284
+ # .with_bsd_style(false)
285
+ # .with_kebab_case_flags(true)
286
+ # .build
287
+ #
288
+ # @return [Array<String>]
289
+ def to_argv(opts = nil)
290
+ Argvise.build(self, opts:)
291
+ end
292
+
293
+ # Converts a hash map into BSD-style command-line arguments.
294
+ #
295
+ # @param opts [Hash]
296
+ # @see to_argv
297
+ # @example
298
+ #
299
+ # require 'argvise'
300
+ # using Argvise::HashRefin
301
+ #
302
+ # { path: '/path/to/dir' }.to_argv_bsd
303
+ # #=> ["-path", "/path/to/dir"]
304
+ #
305
+ # @return [Array<String>]
306
+ def to_argv_bsd(options = {})
307
+ # if options is not Hash Type => {}
308
+ options = {} unless options.is_a?(::Hash)
309
+
310
+ opts = options.merge({ bsd_style: true })
311
+ Argvise.build(self, opts:)
312
+ end
313
+ end
314
+
315
+ # Converts a hash map into command-line arguments.
258
316
  #
259
- # == Example:
317
+ # Monkey Patching:
260
318
  #
261
- # { v: true, path: '/path/to/dir' }.to_argv
262
- # #=> ["-v", "--path", "/path/to/dir"]
319
+ # - Hash#to_argv
320
+ # - Hash#to_argv_bsd
263
321
  #
264
- # == params:
322
+ # @example
265
323
  #
266
- # - opts: See also [Argvise::new]
324
+ # require 'argvise'
267
325
  #
268
- # == raw_cmd_hash.to_argv is equivalent to:
326
+ # module A
327
+ # module_function
328
+ # include Argvise::HashMixin
269
329
  #
270
- # raw_cmd_hash
271
- # .then(&Argvise.new_proc)
272
- # .with_bsd_style(false)
273
- # .with_kebab_case_flags(true)
274
- # .build
330
+ # def demo
331
+ # puts({ path: '/path/to/dir' }.to_argv)
332
+ # #=> ["--path", "/path/to/dir"]
275
333
  #
276
- # ---
334
+ # puts({ path: '/path/to/dir' }.to_argv_bsd)
335
+ # #=> ["-path", "/path/to/dir"]
336
+ # end
337
+ # end
277
338
  #
278
- # sig { params(opts: T.nilable(Hash)).returns(T::Array[String]) }
279
- def to_argv(opts = nil)
280
- Argvise.build(self, opts:)
339
+ # A.demo
340
+ # Hash.method_defined?(:to_argv) # => true
341
+ # {}.respond_to?(:to_argv) #=> true
342
+ module HashMixin
343
+ def self.included(_host)
344
+ ::Hash.include(HashExt)
345
+ end
281
346
  end
282
347
  end
@@ -0,0 +1,41 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ # To maintain `mruby` compatibility, define `private_constant` and
5
+ # `refinements` in **refinement.rb** rather than in **core.rb**.
6
+
7
+ class Argvise # rubocop:disable Style/ClassAndModuleChildren
8
+ # Probably no need to mark this as private.
9
+ # private_constant :HashExt
10
+
11
+ # Refinements:
12
+ #
13
+ # - Hash#to_argv
14
+ # - Hash#to_argv_bsd
15
+ #
16
+ # @example
17
+ #
18
+ # require 'argvise'
19
+ # class A
20
+ # using Argvise::HashRefin
21
+ # def self.demo
22
+ # puts({ target: "wasm32-wasip2" }.to_argv)
23
+ # # => ["--target", "wasm32-wasip2"]
24
+ #
25
+ # puts({ target: "wasm32-wasip2" }.to_argv_bsd)
26
+ # # => ["-target", "wasm32-wasip2"]
27
+ #
28
+ # puts({}.respond_to?(:to_argv)) #=> true
29
+ # end
30
+ # end
31
+ #
32
+ # A.demo
33
+ # Hash.method_defined?(:to_argv) # => false
34
+ # {}.respond_to?(:to_argv) #=> false
35
+ #
36
+ module HashRefin
37
+ refine ::Hash do
38
+ import_methods HashExt
39
+ end
40
+ end
41
+ end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  class Argvise
5
- VERSION = '0.0.8'
5
+ VERSION = '0.0.10'
6
6
  end
data/lib/argvise.rb CHANGED
@@ -3,3 +3,4 @@
3
3
 
4
4
  require_relative 'argvise/version'
5
5
  require_relative 'argvise/core'
6
+ require_relative 'argvise/refinement'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: argvise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - 2moe
@@ -11,26 +11,24 @@ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Provides flexible command-line argument generation with support for complex
13
13
  data structures
14
- email:
15
- - m@tmoe.me
16
14
  executables: []
17
15
  extensions: []
18
16
  extra_rdoc_files: []
19
17
  files:
20
18
  - ".rubocop.yml"
19
+ - ".yardopts"
21
20
  - License
22
- - bin/build.rb
23
- - bin/console.rb
24
21
  - docs/Readme.md
25
22
  - lib/argvise.rb
26
23
  - lib/argvise/core.rb
24
+ - lib/argvise/refinement.rb
27
25
  - lib/argvise/version.rb
28
- - rbi/lib/argvise.rbi
29
26
  homepage: https://github.com/2moe/argvise-gem
30
27
  licenses:
31
28
  - Apache-2.0
32
29
  metadata:
33
30
  homepage_uri: https://github.com/2moe/argvise-gem
31
+ documentation_uri: https://2moe.github.io/argvise-gem/
34
32
  rdoc_options: []
35
33
  require_paths:
36
34
  - lib
data/bin/build.rb DELETED
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # typed: ignore
3
- # frozen_string_literal: true
4
-
5
- require 'pathname'
6
-
7
- Pathname(__dir__ || File.dirname(__FILE__))
8
- .parent
9
- .then { Dir.chdir(it) }
10
-
11
- proj = 'argvise'
12
-
13
- system <<~CMD
14
- gem uninstall #{proj}
15
- gem build #{proj}
16
- gem install #{proj}
17
- CMD
18
-
19
- # gem push argvise-*.gem
data/bin/console.rb DELETED
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # typed: ignore
3
- # frozen_string_literal: true
4
-
5
- # lib_path = File.expand_path('../lib', __dir__)
6
- # exec "irb -I #{lib_path} -r argvise"
7
-
8
- # require "bundler/setup"
9
- # require "argvise"
10
- require 'irb'
11
- require_relative '../lib/argvise'
12
-
13
- puts "Argvise: #{Argvise::VERSION}"
14
-
15
- def puts_division_line
16
- puts
17
- puts '-' * 80
18
- end
19
-
20
- raw_cmd = {
21
- compiler: nil,
22
- build: nil,
23
- pack_type: 'tar+zstd',
24
- push: true,
25
- v: true,
26
- f: 'p2',
27
- tag: ['v0.0.1', 'beta'],
28
- platform: 'wasi/wasm',
29
- label: {
30
- maintainer: 'user',
31
- description: 'Demo'
32
- },
33
- "/path/to/dir": nil
34
- }
35
-
36
- puts 'GNU-style + kebab_case_flags(false)'
37
- raw_cmd
38
- .then(&Argvise.new_proc)
39
- .with_bsd_style(false)
40
- .with_kebab_case_flags(false)
41
- .build
42
- .display
43
-
44
- puts_division_line
45
- # -----------
46
-
47
- puts 'GNU-style + kebab_case_flags(true)'
48
- raw_cmd
49
- .to_argv
50
- .display
51
-
52
- puts_division_line
53
- # -----------
54
-
55
- puts 'BSD-style + kebab_case_flags(true)'
56
- raw_cmd
57
- .then(&Argvise.new_proc)
58
- .with_bsd_style
59
- .with_kebab_case_flags
60
- .build
61
- .display
62
-
63
- puts_division_line
64
- # -----------
65
-
66
- IRB.start
data/rbi/lib/argvise.rbi DELETED
@@ -1,37 +0,0 @@
1
- # rubocop:disable Style/Documentation, Lint/MissingCopEnableDirective
2
- # typed: true
3
- # frozen_string_literal: true
4
-
5
- class Argvise
6
- class << self
7
- sig do
8
- params(
9
- raw_cmd_hash: Hash,
10
- opts: T.nilable(T::Hash[Symbol, T::Boolean])
11
- ).returns(T::Array[String])
12
- end
13
- def build(raw_cmd_hash, opts: nil); end
14
- end
15
-
16
- sig do
17
- params(
18
- raw_cmd_hash: Hash,
19
- opts: T.nilable(T::Hash[Symbol, T::Boolean])
20
- ).void
21
- end
22
- def initialize(raw_cmd_hash, opts: nil); end
23
-
24
- sig { params(value: T::Boolean).returns(T.self_type) }
25
- def with_bsd_style(value = true); end # rubocop:disable Style/OptionalBooleanParameter
26
-
27
- sig { params(value: T::Boolean).returns(T.self_type) }
28
- def with_kebab_case_flags(value = true); end # rubocop:disable Style/OptionalBooleanParameter
29
-
30
- sig { returns(T::Array[String]) }
31
- def build; end
32
- end
33
-
34
- class ::Hash
35
- sig { params(opts: T.nilable(Hash)).returns(T::Array[String]) }
36
- def to_argv(opts = nil); end
37
- end