argvise 0.0.6 → 0.0.8

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: e02579f4619b47f97e46fe3052e577680cd88ba737f742fe581fc55ef7a54527
4
- data.tar.gz: '08e79eab0d15b6ec23367d39d23e60dbbc0c969b32e632d6aabb54727136d0c1'
3
+ metadata.gz: 96b6f0c2b58c2c978c647f988896d96377fa798b5df00eb372d8f2c13de6d479
4
+ data.tar.gz: ebdd6ef0219a35ab0c585f9310be93ac6f8a22b6376289002b8c414e4ffa6b4e
5
5
  SHA512:
6
- metadata.gz: 87b6122a07799b34702cdc391d8e9c5219ae93c1380f948d0c7359ec71c94e1256274ee03dfd24becd2b0c91f1f2c6992d3a4c8418333dd0a72d8545099a2cc9
7
- data.tar.gz: de14f0f04cace2b164919228c0126692682acfaab406cb710b27828f1db1731f9a59281609cd5c09aab4344e78aa9a11f4f55e2148c0022e404bbd636bf36ccc
6
+ metadata.gz: 6124154af43827d0b5d65d5c086ecb0941daf7f5b56a35655072ee6ba75486340d0eede11aebeb29e95cf69540cd3932e41f0d498d578e68e8ea580abef9ece2
7
+ data.tar.gz: 82a72a33658ea1e190a6f16f181e2d4a9f4c6bad414aa815307e4118a45d53624685809488e276ab84609509467b9fa7e7cda4001e89cfb3a428b073de6247a4
data/docs/Readme.md CHANGED
@@ -20,7 +20,7 @@ system "gem install argvise"
20
20
  require 'argvise'
21
21
 
22
22
  raw_cmd_hash = {
23
- cargo: nil, b: nil, r: true, target: "wasm32-wasip2"
23
+ cargo: (), b: (), r: true, target: "wasm32-wasip2"
24
24
  }
25
25
 
26
26
  raw_cmd_hash
@@ -81,6 +81,7 @@ gem install argvise
81
81
  | `{ "-k2": nil }` | `["-k2"]` |
82
82
  | `{ "--r_a-w_": nil }` | `["--r_a-w_"]` |
83
83
  | `{ key: nil }` | `["key"]` |
84
+ | `{ key: () }` | `["key"]` |
84
85
  | `{ key: [] }` | `[]` |
85
86
  | `{ key: {} }` | `[]` |
86
87
  | `{ key: false }` | `[]` |
@@ -89,7 +90,6 @@ gem install argvise
89
90
  | `{ k: ["a", "b"] }` | `["-k", "a", "-k", "b"]` |
90
91
  | `{ k: { a: 1, b: 2 } }` | `["-k", "a=1", "-k", "b=2"]` |
91
92
 
92
-
93
93
  ### GNU Style
94
94
 
95
95
  | Hash Format | Result |
@@ -101,7 +101,7 @@ gem install argvise
101
101
 
102
102
  ---
103
103
 
104
- #### `with_kebab_case_flags(true)`:
104
+ #### `with_kebab_case_flags(true)`
105
105
 
106
106
  | Hash Format | Result |
107
107
  | ----------------- | ------------- |
@@ -109,13 +109,12 @@ gem install argvise
109
109
 
110
110
  ---
111
111
 
112
- #### `with_kebab_case_flags(false)`:
112
+ #### `with_kebab_case_flags(false)`
113
113
 
114
114
  | Hash Format | Result |
115
115
  | ----------------- | ------------- |
116
116
  | `{ key_b: true }` | `["--key_b"]` |
117
117
 
118
-
119
118
  ### BSD Style
120
119
 
121
120
  | Hash Format | Result |
@@ -127,7 +126,9 @@ gem install argvise
127
126
 
128
127
  ---
129
128
 
130
- #### `with_kebab_case_flags(true)`:
129
+ <!-- markdownlint-disable MD024 no-duplicate-heading -->
130
+
131
+ #### `with_kebab_case_flags(true)`
131
132
 
132
133
  | Hash Format | Result |
133
134
  | ----------------- | ------------ |
@@ -135,13 +136,12 @@ gem install argvise
135
136
 
136
137
  ---
137
138
 
138
- #### `with_kebab_case_flags(false)`:
139
+ #### `with_kebab_case_flags(false)`
139
140
 
140
141
  | Hash Format | Result |
141
142
  | ----------------- | ------------ |
142
143
  | `{ key_d: true }` | `["-key_d"]` |
143
144
 
144
-
145
145
  ### Notes
146
146
 
147
147
  > When the value of a flag key is `nil`, the `kebab_case_flags` option has
@@ -158,8 +158,8 @@ gem install argvise
158
158
  require 'argvise'
159
159
 
160
160
  raw_cmd_hash = {
161
- docker: nil, #=> docker
162
- build: nil,
161
+ docker: (), #=> docker
162
+ build: (),
163
163
  push: true, #=> --push
164
164
  tag: ["ghcr.io/[user]/repo:latest", "ghcr.io/[user]/repo:v0.0.1"], #=> --tag ghcr... --tag ghcr..0.0.1
165
165
  platform: "wasi/wasm", #=> --platform wasi/wasm
@@ -168,7 +168,7 @@ raw_cmd_hash = {
168
168
  description: "A Docker build example"
169
169
  }, # => --label maintainer=user --label description=A..example
170
170
  file: "wasi.dockerfile",
171
- path: nil,
171
+ path: (),
172
172
  }
173
173
 
174
174
  Argvise.build(raw_cmd_hash)
@@ -181,7 +181,7 @@ Argvise.build(raw_cmd_hash)
181
181
  # ]
182
182
  ```
183
183
 
184
- ### Lambda Shortcut
184
+ ### Shortcut
185
185
 
186
186
  ```ruby
187
187
  { v: true, dir: '/path/to/dir' }.to_argv
@@ -191,13 +191,14 @@ Argvise.build(raw_cmd_hash)
191
191
  ### Configurable builder
192
192
 
193
193
  > Required
194
- > - argvise: >= v0.0.4
195
- > - ruby: >= v3.1.0
194
+ >
195
+ > - argvise: >= v0.0.6
196
+ > - ruby: >= v3.1.0
196
197
 
197
198
  ```ruby
198
199
  raw_cmd = {
199
- compiler: nil,
200
- build: nil,
200
+ compiler: (),
201
+ build: (),
201
202
  pack_type: 'tar+zstd',
202
203
  push: true,
203
204
  v: true,
@@ -208,11 +209,12 @@ raw_cmd = {
208
209
  maintainer: 'user',
209
210
  description: 'Demo'
210
211
  },
211
- "/path/to/dir": nil
212
+ "/path/to/dir": ()
212
213
  }
213
214
 
214
215
  p '----------------'
215
216
  p "GNU-style + kebab case flags=false"
217
+ # argvise: >= v0.0.4
216
218
  raw_cmd
217
219
  .then(&Argvise.new_proc)
218
220
  .with_bsd_style(false)
@@ -224,6 +226,7 @@ raw_cmd
224
226
 
225
227
  p '----------------'
226
228
  p 'GNU-style + kebab-case-flags=true'
229
+ # argvise: >= v0.0.6
227
230
  raw_cmd
228
231
  .to_argv
229
232
  .display
@@ -232,6 +235,7 @@ raw_cmd
232
235
 
233
236
  p '----------------'
234
237
  p 'BSD-style + kebab-case-flags=true'
238
+ # argvise: >= v0.0.4
235
239
  raw_cmd
236
240
  .then(&Argvise.new_proc)
237
241
  .with_bsd_style
@@ -248,15 +252,15 @@ raw_cmd
248
252
 
249
253
  #### GNU style
250
254
 
251
- - `{ verbose: true }` => "--verbose"
252
- - `{ v: true }` => "-v"
253
- - `{ v: false }` => no argument generated
255
+ - `{ verbose: true }` => `["--verbose"]`
256
+ - `{ v: true }` => `["-v"]`
257
+ - `{ v: false }` => `[]`
254
258
 
255
259
  #### BSD style
256
260
 
257
- - `{ verbose: true }` => "-verbose"
258
- - `{ v: true }` => "-v"
259
- - `{ v: false }` => no argument generated
261
+ - `{ verbose: true }` => `["-verbose"]`
262
+ - `{ v: true }` => `["-v"]`
263
+ - `{ v: false }` => `[]`
260
264
 
261
265
  ### String
262
266
 
@@ -296,9 +300,9 @@ raw_cmd
296
300
 
297
301
  ## Nil => Raw
298
302
 
299
- - `{ cargo: nil, b: nil}` => `["cargo", "b"]`
300
- - `{ "-fv": nil}` => `["-fv"]`
301
-
303
+ - `{ cargo: () }` => `["cargo"]`
304
+ - `{ cargo: nil, b: nil }` => `["cargo", "b"]`
305
+ - `{ "-fv": nil }` => `["-fv"]`
302
306
 
303
307
  ## Changelog
304
308
 
@@ -306,7 +310,7 @@ raw_cmd
306
310
 
307
311
  Breaking Changes:
308
312
 
309
- - `.hash_to_argv` => `Hash.to_argv(opts)`
313
+ - `cmd_hash |> hash_to_argv` => `cmd_hash.to_argv(opts)`
310
314
  - i.e.,
311
315
  - old: `{a: true}.then(&hash_to_argv)`
312
316
  - new: `{a: true}.to_argv`
@@ -19,9 +19,9 @@
19
19
  #
20
20
  # === GNU Style:
21
21
  # - Boolean values:
22
- # - `{ verbose: true }` => "--verbose"
23
- # - `{ v: true }` => "-v"
24
- # - `{ v: false }` => no argument generated
22
+ # - `{ verbose: true }` => ["--verbose"]
23
+ # - `{ v: true }` => ["-v"]
24
+ # - `{ v: false }` => [] #no argument generated
25
25
  # - String values:
26
26
  # - `{ f: "a.txt" }` => ["-f", "a.txt"]
27
27
  # - `{ file: "a.txt" }` => ["--file", "a.txt"]
@@ -34,9 +34,9 @@
34
34
  #
35
35
  # === BSD Style:
36
36
  # - Boolean values:
37
- # - `{ verbose: true }` => "-verbose"
38
- # - `{ v: true }` => "-v"
39
- # - `{ v: false }` => no argument generated
37
+ # - `{ verbose: true }` => ["-verbose"]
38
+ # - `{ v: true }` => ["-v"]
39
+ # - `{ v: false }` => [] #no argument generated
40
40
  # - String values:
41
41
  # - `{ f: "a.txt" }` => ["-f", "a.txt"]
42
42
  # - `{ file: "a.txt" }` => ["-file", "a.txt"]
@@ -254,7 +254,7 @@ class Argvise
254
254
  end
255
255
 
256
256
  class ::Hash # rubocop:disable Style/Documentation
257
- # A convenient lambda method: converts a hash into command-line arguments
257
+ # Converts a hash into command-line arguments
258
258
  #
259
259
  # == Example:
260
260
  #
@@ -277,6 +277,6 @@ class ::Hash # rubocop:disable Style/Documentation
277
277
  #
278
278
  # sig { params(opts: T.nilable(Hash)).returns(T::Array[String]) }
279
279
  def to_argv(opts = nil)
280
- Argvise.build(self, opts: opts)
280
+ Argvise.build(self, opts:)
281
281
  end
282
282
  end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  class Argvise
5
- VERSION = '0.0.6'
5
+ VERSION = '0.0.8'
6
6
  end
data/lib/argvise.rb CHANGED
@@ -2,4 +2,4 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative 'argvise/version'
5
- require_relative 'core'
5
+ require_relative 'argvise/core'
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.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - 2moe
@@ -23,8 +23,8 @@ files:
23
23
  - bin/console.rb
24
24
  - docs/Readme.md
25
25
  - lib/argvise.rb
26
+ - lib/argvise/core.rb
26
27
  - lib/argvise/version.rb
27
- - lib/core.rb
28
28
  - rbi/lib/argvise.rbi
29
29
  homepage: https://github.com/2moe/argvise-gem
30
30
  licenses: