clino 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d86d5698e312851641e338834676b2f93bcb7776af31f9422b0743853faeccf7
4
- data.tar.gz: 338b0887ebde6716a29895038dc82c3782f5802b26ec5fac30ea646a7bafb62f
3
+ metadata.gz: b5da44c716b390337107099e942d034e182f87d0c201db938ce33edb25afec00
4
+ data.tar.gz: aab08f2034e3334083e04f85073a7e3762eaa095a64c5514107e3ddb5899a4e9
5
5
  SHA512:
6
- metadata.gz: 0bed4f9fcc8f06d4826825cff4c8e5f288268414faeca9696fe8afac0f8fc28acc77dfdb244247023dce2ea64289f9f07fa3aeb0f0d079b5eb30d1f3be316ca2
7
- data.tar.gz: 46e68b260f20bc9fcd550c9be9306bcc9d72d7c32bf63cc6fea9ea8fd333e07459b8a3981f34c411b4c8b646e5c2f5751037d061d860533cab982d212d092de3
6
+ metadata.gz: b0a9cb88be968997e96874262e24adb6a6d005babec72d6c797ba6871f5f0f1cfc6d76dffd3a2fc05ac4a88d10ab5182d468a80f746dfdfcebc3622122952e09
7
+ data.tar.gz: 65354f82b88c9bf681233a6e062aa7c83b848f09c6866f1c3dc51ce48352f707d8699834363ca604d69102b291adecd6f9220fe6526e0ff7a8d13801c3079d2e
data/README.md CHANGED
@@ -6,12 +6,20 @@ It is inspired by the [Thor](https://github.com/rails/thor) and [Typer](https://
6
6
 
7
7
  ## Installation
8
8
 
9
- Add this line to your application's Gemfile:
9
+ Install this gem as a regular gem:
10
+
11
+ ```bash
12
+ gem install clino
13
+ ```
14
+
15
+ or add this line to your application's Gemfile:
10
16
 
11
17
  ```ruby
12
18
  gem 'clino'
13
19
  ```
14
20
 
21
+ Link: [RubyGems](https://rubygems.org/gems/clino)
22
+
15
23
  ## Usage
16
24
 
17
25
  ### Interfaces
@@ -164,7 +172,9 @@ Unfortunately, ruby doesn't allow inspecting the method's signature default valu
164
172
 
165
173
  #### Randomizer Advanced Example
166
174
 
167
- Let's write an advanced version of the randomizer that has CLI signature.
175
+ Let's write an advanced version of the randomizer that has CLI signature.
176
+
177
+ Our entry point is the `run` method, which is called with the parsed and validated input.
168
178
 
169
179
  ```ruby
170
180
  # randomizer.rb
@@ -210,7 +220,7 @@ RandomGeneratorCLI.new.start
210
220
  Run the script with the following command:
211
221
 
212
222
  ```bash
213
- ruby randomizer.rb 1 2 --alg uni --i y # => some number from [1.0, 2.0]
223
+ ruby randomizer.rb 1 2 --alg uni --i # => some number from [1.0, 2.0]
214
224
  ```
215
225
 
216
226
  Get help with the following command:
@@ -247,7 +257,7 @@ Options:
247
257
  # Algorithm to use (uni or exp)
248
258
  --alg (-a) [string]
249
259
  # Include upper bound
250
- [--[no-]incl] (-[no-]i) [bool] [default: false]
260
+ [--incl] (-i) [bool] [default: false]
251
261
 
252
262
  Usage: randomizer.rb [arguments] [options]
253
263
  Use --h, --help to print this help message.
@@ -316,7 +326,6 @@ Use --h, --help to print this help message.
316
326
  - [ ] Add CI/CD
317
327
  - [ ] Add more examples
318
328
  - [ ] Create a proper documentation
319
- - [ ] Better boolean flag handling
320
329
 
321
330
  ## Contributing
322
331
 
data/clino.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  that allows you to create a CLI application with minimal effort."
14
14
  spec.homepage = "https://github.com/snusmumr1000/Clino"
15
15
  spec.license = "MIT"
16
- spec.required_ruby_version = ">= 2.6.0"
16
+ spec.required_ruby_version = ">= 3.2.2"
17
17
 
18
18
  # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
19
19
 
@@ -22,14 +22,7 @@ module InputParser
22
22
  OptionParser.new do |opt|
23
23
  signature.opts.each_key do |name|
24
24
  signature_opt = signature.opts[name]
25
- type = signature_opt.type
26
25
  aliases = signature_opt.aliases
27
- if type == :bool
28
- opt.on(*aliases, "--[no-]#{name}") do |v|
29
- input[name] = v
30
- end
31
- next
32
- end
33
26
 
34
27
  if signature_opt.required?
35
28
  opt.on(*aliases, "--#{name} #{name.upcase}") do |v|
@@ -49,7 +49,6 @@ class CliSignature
49
49
  unless @opts.empty?
50
50
  @help += "\nOptions:\n"
51
51
  @opts.each do |name, option|
52
- name = "[no-]#{name}" if option.type == :bool
53
52
  opt_part = " #{option.required? ? "--#{name}" : "[--#{name}]"}"
54
53
  if option.aliases && !option.aliases.empty?
55
54
  aliases = option.aliases.join(", ")
@@ -16,8 +16,7 @@ class Cli
16
16
 
17
17
  def opt(name, type: :string, desc: nil, aliases: [], default: :none)
18
18
  @opt_buffer ||= {}
19
- bool_prefix = type == :bool ? "[no-]" : ""
20
- aliases = aliases.map { |a| "-#{bool_prefix}#{general_strip a, "-"}" }
19
+ aliases = aliases.map { |a| "--#{general_strip a, "-"}" }
21
20
  default = load_input type, default unless default == :none
22
21
  @opt_buffer[name] = Base::OptSignature.new(name: name, type: type, default: default, desc: desc,
23
22
  aliases: aliases)
data/lib/clino/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clino
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tikhon Zaikin
@@ -53,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 2.6.0
56
+ version: 3.2.2
57
57
  required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="