argvise 0.0.5 → 0.0.6

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: cc2e3625fabe3294535d920c085b82f1c2718032de5f3921a7a9f74424c1ca5f
4
- data.tar.gz: 2005628bc2fc53ea8937a310111b4217289051e3c634d5960287ed9e4db4dca0
3
+ metadata.gz: e02579f4619b47f97e46fe3052e577680cd88ba737f742fe581fc55ef7a54527
4
+ data.tar.gz: '08e79eab0d15b6ec23367d39d23e60dbbc0c969b32e632d6aabb54727136d0c1'
5
5
  SHA512:
6
- metadata.gz: 1f78e1ea42b3d355ec65da36c69bbf31b7dfa7386c7483ed42c625ef15dc826f052e7009f040a47ef0f685a2f4d26de347edfeeba9c53c09cdb7941bc5b6915a
7
- data.tar.gz: a9c6c99a0590f822f5dda6782a3a12c664008c8eff472c234f004e9b2fb69033e12dba58d8efd6c9bb77ec449cc97dab121cf875e80535f226f0ec29c3aea45c
6
+ metadata.gz: 87b6122a07799b34702cdc391d8e9c5219ae93c1380f948d0c7359ec71c94e1256274ee03dfd24becd2b0c91f1f2c6992d3a4c8418333dd0a72d8545099a2cc9
7
+ data.tar.gz: de14f0f04cace2b164919228c0126692682acfaab406cb710b27828f1db1731f9a59281609cd5c09aab4344e78aa9a11f4f55e2148c0022e404bbd636bf36ccc
data/bin/console.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ # typed: ignore
2
3
  # frozen_string_literal: true
3
4
 
4
5
  # lib_path = File.expand_path('../lib', __dir__)
5
6
  # exec "irb -I #{lib_path} -r argvise"
6
7
 
8
+ # require "bundler/setup"
9
+ # require "argvise"
7
10
  require 'irb'
8
11
  require_relative '../lib/argvise'
9
12
 
@@ -43,7 +46,7 @@ puts_division_line
43
46
 
44
47
  puts 'GNU-style + kebab_case_flags(true)'
45
48
  raw_cmd
46
- .then(&hash_to_argv)
49
+ .to_argv
47
50
  .display
48
51
 
49
52
  puts_division_line
data/docs/Readme.md CHANGED
@@ -19,16 +19,21 @@ system "gem install argvise"
19
19
  # RUBY
20
20
  require 'argvise'
21
21
 
22
- { cargo: nil, b: nil, r: true, target: "wasm32-wasip2" }
23
- .then(&hash_to_argv)
22
+ raw_cmd_hash = {
23
+ cargo: nil, b: nil, r: true, target: "wasm32-wasip2"
24
+ }
25
+
26
+ raw_cmd_hash
27
+ .to_argv
28
+ # .to_argv({bsd_style: false, kebab_case_flags: true})
24
29
 
25
30
  #=> ["cargo", "b", "-r", "--target", "wasm32-wasip2"]
26
31
  ```
27
32
 
28
- `raw_cmd_hash.then(&hash_to_argv)` is equivalent to:
33
+ `raw_cmd_hash.to_argv` is equivalent to:
29
34
 
30
35
  ```ruby
31
- { cargo: nil, b: nil, r: true, target: "wasm32-wasip2" }
36
+ raw_cmd_hash
32
37
  .then(&Argvise.new_proc)
33
38
  .with_bsd_style(false) #=> GNU style
34
39
  .with_kebab_case_flags(true) #=> replace "--cli_flag" with "--cli-flag"
@@ -37,6 +42,8 @@ require 'argvise'
37
42
 
38
43
  ## Installation
39
44
 
45
+ ### Ruby MRI
46
+
40
47
  Add this line to your application's Gemfile:
41
48
 
42
49
  ```ruby
@@ -61,6 +68,10 @@ Or install it directly:
61
68
  gem install argvise
62
69
  ```
63
70
 
71
+ ### mruby
72
+
73
+ [More details](../mruby/Readme.md)
74
+
64
75
  ## Conversion Rules
65
76
 
66
77
  ### Common
@@ -173,7 +184,7 @@ Argvise.build(raw_cmd_hash)
173
184
  ### Lambda Shortcut
174
185
 
175
186
  ```ruby
176
- { v: true, dir: '/path/to/dir' }.then(&hash_to_argv)
187
+ { v: true, dir: '/path/to/dir' }.to_argv
177
188
  # => ["-v", "--dir", "/path/to/dir"]
178
189
  ```
179
190
 
@@ -214,7 +225,7 @@ raw_cmd
214
225
  p '----------------'
215
226
  p 'GNU-style + kebab-case-flags=true'
216
227
  raw_cmd
217
- .then(&hash_to_argv)
228
+ .to_argv
218
229
  .display
219
230
 
220
231
  #=> ["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"]
@@ -287,3 +298,15 @@ raw_cmd
287
298
 
288
299
  - `{ cargo: nil, b: nil}` => `["cargo", "b"]`
289
300
  - `{ "-fv": nil}` => `["-fv"]`
301
+
302
+
303
+ ## Changelog
304
+
305
+ ### v0.0.6 (2025-11-05)
306
+
307
+ Breaking Changes:
308
+
309
+ - `.hash_to_argv` => `Hash.to_argv(opts)`
310
+ - i.e.,
311
+ - old: `{a: true}.then(&hash_to_argv)`
312
+ - new: `{a: true}.to_argv`
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  class Argvise
5
- VERSION = '0.0.5'
5
+ VERSION = '0.0.6'
6
6
  end
data/lib/core.rb CHANGED
@@ -253,23 +253,30 @@ class Argvise
253
253
  end
254
254
  end
255
255
 
256
- # A convenient lambda method: converts a hash into command-line arguments
257
- #
258
- # == Example:
259
- # { v: true, path: '/path/to/dir' }.then(&hash_to_argv)
260
- # #=> ["-v", "--path", "/path/to/dir"]
261
- #
262
- # == raw_cmd_hash.then(&hash_to_argv) is equivalent to:
263
- #
264
- # raw_cmd_hash
265
- # .then(&Argvise.new_proc)
266
- # .with_bsd_style(false)
267
- # .with_kebab_case_flags(true)
268
- # .build
269
- #
270
- # sig { returns(T.proc.params(raw_cmd_hash: Hash).returns(T::Array[String])) }
271
- def hash_to_argv
272
- ->(raw_cmd_hash) do
273
- Argvise.build(raw_cmd_hash)
256
+ class ::Hash # rubocop:disable Style/Documentation
257
+ # A convenient lambda method: converts a hash into command-line arguments
258
+ #
259
+ # == Example:
260
+ #
261
+ # { v: true, path: '/path/to/dir' }.to_argv
262
+ # #=> ["-v", "--path", "/path/to/dir"]
263
+ #
264
+ # == params:
265
+ #
266
+ # - opts: See also [Argvise::new]
267
+ #
268
+ # == raw_cmd_hash.to_argv is equivalent to:
269
+ #
270
+ # raw_cmd_hash
271
+ # .then(&Argvise.new_proc)
272
+ # .with_bsd_style(false)
273
+ # .with_kebab_case_flags(true)
274
+ # .build
275
+ #
276
+ # ---
277
+ #
278
+ # sig { params(opts: T.nilable(Hash)).returns(T::Array[String]) }
279
+ def to_argv(opts = nil)
280
+ Argvise.build(self, opts: opts)
274
281
  end
275
282
  end
data/rbi/lib/argvise.rbi CHANGED
@@ -21,15 +21,17 @@ class Argvise
21
21
  end
22
22
  def initialize(raw_cmd_hash, opts: nil); end
23
23
 
24
- sig { params(value: T::Boolean).returns(self) }
24
+ sig { params(value: T::Boolean).returns(T.self_type) }
25
25
  def with_bsd_style(value = true); end # rubocop:disable Style/OptionalBooleanParameter
26
26
 
27
- sig { params(value: T::Boolean).returns(self) }
27
+ sig { params(value: T::Boolean).returns(T.self_type) }
28
28
  def with_kebab_case_flags(value = true); end # rubocop:disable Style/OptionalBooleanParameter
29
29
 
30
30
  sig { returns(T::Array[String]) }
31
31
  def build; end
32
32
  end
33
33
 
34
- sig { returns(T.proc.params(raw_cmd_hash: T::Hash[T.any(Symbol, String), T.untyped]).returns(T::Array[String])) }
35
- def hash_to_argv; end
34
+ class ::Hash
35
+ sig { params(opts: T.nilable(Hash)).returns(T::Array[String]) }
36
+ def to_argv(opts = nil); end
37
+ end
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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - 2moe
@@ -19,7 +19,6 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ".rubocop.yml"
21
21
  - License
22
- - argvise.gemspec
23
22
  - bin/build.rb
24
23
  - bin/console.rb
25
24
  - docs/Readme.md
@@ -48,5 +47,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
47
  requirements: []
49
48
  rubygems_version: 3.7.2
50
49
  specification_version: 4
51
- summary: Turns a hash into CLI arguments
50
+ summary: Converts a hash into CLI arguments [Array]
52
51
  test_files: []
data/argvise.gemspec DELETED
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/argvise/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'argvise'
7
- # spec.version = '0.0.1'
8
- spec.version = Argvise::VERSION
9
- spec.authors = ['2moe']
10
- spec.email = ['m@tmoe.me']
11
-
12
- spec.summary = 'Turns a hash into CLI arguments'
13
- spec.description = 'Provides flexible command-line argument generation with support for complex data structures'
14
- spec.license = 'Apache-2.0'
15
- # spec.extra_rdoc_files = ['docs/rdoc/Readme.rdoc']
16
- spec.required_ruby_version = '>= 3.1.0'
17
- # spec.metadata['allowed_push_host'] = "TODO: Set to your gem server 'https://example.com'"
18
-
19
- spec.homepage = 'https://github.com/2moe/argvise-gem'
20
- spec.metadata['homepage_uri'] = spec.homepage
21
- # spec.metadata['source_code_uri'] = spec.homepage
22
- # spec.metadata['changelog_uri'] = "TODO: Put your gem's CHANGELOG.md URL here."
23
-
24
- # Specify which files should be added to the gem when it is released.
25
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
- # gemspec = File.basename(__FILE__)
27
- spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
28
- ls.readlines("\x0", chomp: true).reject do |f|
29
- # (f == gemspec) ||
30
- f.start_with?(
31
- # bin/ test/ Gemfile Rakefile assets docs/Readme-zh-
32
- *%w[
33
- spec/ features/ .git .github appveyor
34
- ]
35
- )
36
- end
37
- end
38
- # spec.bindir = 'exe'
39
- # spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
40
- spec.require_paths = ['lib']
41
-
42
- # Uncomment to register a new dependency of your gem
43
- # spec.add_dependency "example-gem", "~> 1.0"
44
-
45
- # For more information and examples about making a new gem, check out our
46
- # guide at: https://bundler.io/guides/creating_gem.html
47
- end