libclimate-ruby 0.14.0 → 0.15.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: f003cbc8499db9924001bc35c3c5312de4e6423151d9acfaa8e835e0f7f331f3
4
- data.tar.gz: 65e7371f5ded01f26074bad1413f329abd8c62237556162cef5ca0e9397deb9d
3
+ metadata.gz: 8a80c08e442469251d0436faea56241a72bb4b3c072d915a8d2ca3272430ee44
4
+ data.tar.gz: 80d05c56fd08159bababfb73e0c277e1cfa610f95fcffe75994199f0e9050918
5
5
  SHA512:
6
- metadata.gz: 52fc0d2b96d707bedb7e12643e0cfc1d9a3724003f7454c8b64bc573b1704360fe8ce366bca0388411957f0420e777629e8e631038c3b6524aebaa2af92cfd9a
7
- data.tar.gz: 5909f06e2b6ad0ca47e3da8d141382e20c93f17f80d2b8ea397364c9c0ebf7159e510373de0ed2a743ece65ae6a78202e9fed8c261f8fdbc692a044876f89f04
6
+ metadata.gz: f88618dd50e250ccc2b15c9500ff97db1fe922394997a1ba9c4ceee38fa73f6830ea17432ea8666647a593befa0cdcfac0df95b78dcfbb85c15114bbcde384ec
7
+ data.tar.gz: ec7c28f7b08747f6e07f6e5c89e7707a8c3837f8b78b5e57693f72b55bc4dd36ee1ef26dcfc75c384b4bccd425927bdb46b568facf605a3db8cf3e02fed55b17
data/README.md CHANGED
@@ -3,15 +3,6 @@ libCLImate, for Ruby
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/libclimate-ruby.svg)](https://badge.fury.io/rb/libclimate-ruby)
5
5
 
6
- ## Introduction
7
-
8
- **libCLImate** is a portable, lightweight mini-framework that encapsulates the common aspects of **C**ommand-**L**ine **I**nterface boilerplate, including:
9
-
10
- - command-line argument parsing and sorting;
11
- - provision of de-facto standard CLI facilities, such as responding to '--help' and '--version';
12
-
13
- **libCLImate.Ruby** is the Ruby version.
14
-
15
6
  ## Table of Contents
16
7
 
17
8
  1. [Introduction](#introduction)
@@ -20,6 +11,17 @@ libCLImate, for Ruby
20
11
  4. [Examples](#examples)
21
12
  5. [Project Information](#project-information)
22
13
 
14
+ ## Introduction
15
+
16
+ **libCLImate** is a portable, lightweight mini-framework that encapsulates the common aspects of **C**ommand-**L**ine **I**nterface boilerplate, including:
17
+
18
+ - command-line argument parsing and sorting, into flags, options, and values;
19
+ - validating given and/or missing arguments;
20
+ - a declarative form of specifying the CLI elements for a program, including associating blocks with flag/option specifications;
21
+ - provision of de-facto standard CLI facilities, such as responding to '--help' and '--version';
22
+
23
+ **libCLImate.Ruby** is the Ruby version.
24
+
23
25
  ## Installation
24
26
 
25
27
  Install via **gem** as in:
@@ -38,7 +40,41 @@ require 'libclimate'
38
40
 
39
41
  ## Components
40
42
 
41
- T.B.C.
43
+ In common with several other variants of **libCLImate**, **libCLImate.Ruby** revolves around a ``Climate`` ``class`` whose initialiser takes a block and acts as a lightweight DSL for concise definition of a command-line parsing instance, as in:
44
+
45
+ ```Ruby
46
+ options = {}
47
+ climate = LibCLImate::Climate.new do |cl|
48
+
49
+ cl.add_flag('--debug', alias: '-d', help: 'runs in Debug mode') do
50
+
51
+ options[:debug] = true
52
+ end
53
+ cl.add_option('--verbosity', alias: '-v', help: 'specifies the verbosity', values: [ 'terse', 'quiet', 'silent', 'chatty' ]) do |o, sp|
54
+
55
+ options[:verbosity] = o.value
56
+ end
57
+ cl.add_alias('--verbosity=chatty', '-c')
58
+
59
+ cl.version = [ 0, 1, 0 ]
60
+
61
+ cl.info_lines = [
62
+
63
+ 'libCLImate.Ruby examples',
64
+ :version,
65
+ "Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications",
66
+ '',
67
+ ]
68
+
69
+ cl.constrain_values = 1..2
70
+ cl.usage_values = "<dir-1> [ <dir-2> ]"
71
+ cl.value_names = [
72
+
73
+ "first directory",
74
+ "second directory",
75
+ ]
76
+ end
77
+ ```
42
78
 
43
79
  ## Examples
44
80
 
@@ -68,10 +104,13 @@ Defect reports, feature requests, and pull requests are welcome on https://githu
68
104
  * [**CLASP**](https://github.com/synesissoftware/CLASP/)
69
105
  * [**CLASP.Go**](https://github.com/synesissoftware/CLASP.Go/)
70
106
  * [**CLASP.js**](https://github.com/synesissoftware/CLASP.js/)
107
+ * [**CLASP.NET**](https://github.com/synesissoftware/CLASP.NET/)
108
+ * [**CLASP.Python**](https://github.com/synesissoftware/CLASP.Python/)
71
109
  * [**CLASP.Ruby**](https://github.com/synesissoftware/CLASP.Ruby/)
72
- * [**libCLImate** (C/C++)](https://github.com/synesissoftware/libCLImate.Ruby)
110
+ * [**libCLImate** (C/C++)](https://github.com/synesissoftware/libCLImate)
73
111
  * [**xqsr3**](https://github.com/synesissoftware.com/libCLImate.Ruby-xml/)
74
112
 
75
113
  ### License
76
114
 
77
115
  **libCLImate.Ruby** is released under the 3-clause BSD license. See [LICENSE](./LICENSE) for details.
116
+
@@ -27,7 +27,7 @@ climate = LibCLImate::Climate.load DATA do |cl|
27
27
  cl.on_option('--verbosity') { |o, a| options[:verbosity] = o.value }
28
28
  end
29
29
 
30
- r = climate.run ARGV
30
+ r = climate.parse_and_verify ARGV
31
31
 
32
32
 
33
33
  # Program-specific processing of flags/options
@@ -87,10 +87,8 @@ libclimate:
87
87
  -
88
88
  version:
89
89
  - 0
90
- - 1
91
- - "2"
92
- ```
93
- ```ruby
90
+ - 2
91
+ - "0"
94
92
  ```
95
93
 
96
94
  ## Usage
@@ -130,7 +128,7 @@ it gives the output:
130
128
 
131
129
  ```
132
130
  libCLImate.Ruby examples
133
- flag_and_option_specifications.from_DATA(.rb) 0.1.2
131
+ flag_and_option_specifications.from_DATA(.rb) 0.2.0
134
132
  Illustrates use of libCLImate.Ruby's specification of flags, options, and aliases, from DATA
135
133
 
136
134
  USAGE: flag_and_option_specifications.from_DATA(.rb) [... flags/options ...] <dir-1> [ <dir-2> ]
@@ -18,7 +18,7 @@ climate = LibCLImate::Climate.load DATA do |cl|
18
18
  cl.on_option('--verbosity') { |o, a| options[:verbosity] = o.value }
19
19
  end
20
20
 
21
- r = climate.run ARGV
21
+ r = climate.parse_and_verify ARGV
22
22
 
23
23
 
24
24
  # Program-specific processing of flags/options
@@ -78,6 +78,6 @@ libclimate:
78
78
  -
79
79
  version:
80
80
  - 0
81
- - 1
82
- - "2"
81
+ - 2
82
+ - "0"
83
83
 
@@ -30,7 +30,7 @@ climate = LibCLImate::Climate.new do |cl|
30
30
  end
31
31
  cl.add_alias('--verbosity=chatty', '-c')
32
32
 
33
- cl.version = [ 0, 0, 1 ]
33
+ cl.version = [ 0, 1, 0 ]
34
34
 
35
35
  cl.info_lines = [
36
36
 
@@ -39,9 +39,17 @@ climate = LibCLImate::Climate.new do |cl|
39
39
  "Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications",
40
40
  '',
41
41
  ]
42
+
43
+ cl.constrain_values = 1..2
44
+ cl.usage_values = "<dir-1> [ <dir-2> ]"
45
+ cl.value_names = [
46
+
47
+ "first directory",
48
+ "second directory",
49
+ ]
42
50
  end
43
51
 
44
- r = climate.run ARGV
52
+ r = climate.parse_and_verify ARGV
45
53
 
46
54
 
47
55
 
@@ -56,6 +64,10 @@ if options[:debug]
56
64
 
57
65
  $stdout.puts 'Debug mode is specified'
58
66
  end
67
+
68
+ # some notional output
69
+
70
+ $stdout.puts "processing in '#{r.values[0]}'" + (r.values.size > 1 ? " and '#{r.values[1]}'" : '')
59
71
  ```
60
72
 
61
73
  ## Usage
@@ -77,6 +89,7 @@ or (in a Unix shell):
77
89
  it gives the output:
78
90
 
79
91
  ```
92
+ flag_and_option_specifications(.rb): first directory not specified; use --help for usage
80
93
  ```
81
94
 
82
95
  ### Show usage
@@ -91,7 +104,7 @@ it gives the output:
91
104
 
92
105
  ```
93
106
  libCLImate.Ruby examples
94
- flag_and_option_specifications.rb 0.0.1
107
+ flag_and_option_specifications.rb 0.1.0
95
108
  Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications
96
109
 
97
110
  USAGE: flag_and_option_specifications.rb [ ... flags and options ... ]
@@ -124,7 +137,7 @@ flags/options:
124
137
  If executed with the arguments
125
138
 
126
139
  ```
127
- ruby examples/flag_and_option_specifications.rb --debug --verbosity=silent
140
+ ruby examples/flag_and_option_specifications.rb dir-1 dir-2 --debug --verbosity=silent
128
141
  ```
129
142
 
130
143
  it gives the output:
@@ -132,6 +145,7 @@ it gives the output:
132
145
  ```
133
146
  verbosity is specified as: silent
134
147
  Debug mode is specified
148
+ processing in 'dir-1' and 'dir-2'
135
149
  ```
136
150
 
137
151
  ### Specify flags and options in short-form
@@ -139,7 +153,7 @@ Debug mode is specified
139
153
  If executed with the arguments
140
154
 
141
155
  ```
142
- ruby examples/flag_and_option_specifications.rb -v silent -d
156
+ ruby examples/flag_and_option_specifications.rb dir-1 dir-2 -v silent -d
143
157
  ```
144
158
 
145
159
  it gives the (same) output:
@@ -147,6 +161,7 @@ it gives the (same) output:
147
161
  ```
148
162
  verbosity is specified as: silent
149
163
  Debug mode is specified
164
+ processing in 'dir-1' and 'dir-2'
150
165
  ```
151
166
 
152
167
  ### Specify flags and options in short-form, including an alias for an option-with-value
@@ -154,7 +169,7 @@ Debug mode is specified
154
169
  If executed with the arguments
155
170
 
156
171
  ```
157
- ruby examples/flag_and_option_specifications.rb -c -d
172
+ ruby examples/flag_and_option_specifications.rb -c -d dir-1 dir-2
158
173
  ```
159
174
 
160
175
  it gives the output:
@@ -162,6 +177,7 @@ it gives the output:
162
177
  ```
163
178
  verbosity is specified as: chatty
164
179
  Debug mode is specified
180
+ processing in 'dir-1' and 'dir-2'
165
181
  ```
166
182
 
167
183
  ### Specify flags and options with combined short-form
@@ -169,7 +185,7 @@ Debug mode is specified
169
185
  If executed with the arguments
170
186
 
171
187
  ```
172
- ruby examples/flag_and_option_specifications.rb -dc
188
+ ruby examples/flag_and_option_specifications.rb -dc dir-1 dir-2
173
189
  ```
174
190
 
175
191
  it gives the (same) output:
@@ -177,5 +193,5 @@ it gives the (same) output:
177
193
  ```
178
194
  verbosity is specified as: chatty
179
195
  Debug mode is specified
196
+ processing in 'dir-1' and 'dir-2'
180
197
  ```
181
-
@@ -21,7 +21,7 @@ climate = LibCLImate::Climate.new do |cl|
21
21
  end
22
22
  cl.add_alias('--verbosity=chatty', '-c')
23
23
 
24
- cl.version = [ 0, 0, 1 ]
24
+ cl.version = [ 0, 1, 0 ]
25
25
 
26
26
  cl.info_lines = [
27
27
 
@@ -30,9 +30,17 @@ climate = LibCLImate::Climate.new do |cl|
30
30
  "Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications",
31
31
  '',
32
32
  ]
33
+
34
+ cl.constrain_values = 1..2
35
+ cl.usage_values = "<dir-1> [ <dir-2> ]"
36
+ cl.value_names = [
37
+
38
+ "first directory",
39
+ "second directory",
40
+ ]
33
41
  end
34
42
 
35
- r = climate.run ARGV
43
+ r = climate.parse_and_verify ARGV
36
44
 
37
45
 
38
46
 
@@ -49,5 +57,7 @@ if options[:debug]
49
57
  end
50
58
 
51
59
 
60
+ # some notional output
52
61
 
62
+ $stdout.puts "processing in '#{r.values[0]}'" + (r.values.size > 1 ? " and '#{r.values[1]}'" : '')
53
63
 
@@ -19,7 +19,7 @@ require 'libclimate'
19
19
 
20
20
  climate = LibCLImate::Climate.new do |cl|
21
21
 
22
- cl.version = [ 0, 0, 1 ]
22
+ cl.version = [ 0, 1, 0 ]
23
23
 
24
24
  cl.info_lines = [
25
25
 
@@ -30,7 +30,7 @@ climate = LibCLImate::Climate.new do |cl|
30
30
  ]
31
31
  end
32
32
 
33
- climate.run ARGV
33
+ climate.parse_and_verify ARGV
34
34
 
35
35
 
36
36
 
@@ -71,7 +71,7 @@ it gives the output:
71
71
 
72
72
  ```
73
73
  libCLImate.Ruby examples
74
- show_usage_and_version.rb 0.0.1
74
+ show_usage_and_version.rb 0.1.0
75
75
  Illustrates use of libCLImate.Ruby's automatic support for '--help' and '--version'
76
76
 
77
77
  USAGE: show_usage_and_version.rb [ ... flags and options ... ]
@@ -96,7 +96,7 @@ If executed with the arguments
96
96
  it gives the output:
97
97
 
98
98
  ```
99
- show_usage_and_version.rb 0.0.1
99
+ show_usage_and_version.rb 0.1.0
100
100
  ```
101
101
 
102
102
  ### Unknown option
@@ -114,4 +114,3 @@ show_usage_and_version.rb: unrecognised flag/option: --unknown=value
114
114
  ```
115
115
 
116
116
  with an exit code of 1
117
-
@@ -10,7 +10,7 @@ require 'libclimate'
10
10
 
11
11
  climate = LibCLImate::Climate.new do |cl|
12
12
 
13
- cl.version = [ 0, 0, 1 ]
13
+ cl.version = [ 0, 1, 0 ]
14
14
 
15
15
  cl.info_lines = [
16
16
 
@@ -21,7 +21,7 @@ climate = LibCLImate::Climate.new do |cl|
21
21
  ]
22
22
  end
23
23
 
24
- climate.run ARGV
24
+ climate.parse_and_verify ARGV
25
25
 
26
26
 
27
27