cli_helper 0.1.8 → 0.1.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: daf61d8cbabeb65a4cca02b574eec433477be112
4
- data.tar.gz: d7bda7e83f7f3c2f9bbabf66df68f0b398b4466f
2
+ SHA256:
3
+ metadata.gz: c1359febf0485d5ce8d1b73f6d6b39b264067e0d860bc07ad183c279385450ed
4
+ data.tar.gz: 58a2e0fc02883f01a9dc89f0cbd4eeb9aa84c75d8b1a9d2fab9104799e7aa20c
5
5
  SHA512:
6
- metadata.gz: 42014bd7d2a2718ba08ab8dc01d0b87f45116903a85634c04b3a104761cd34e48ccec049b1f51bb18b9c55c83371fe1e78adbb34a1a9b9e33d46d017bb93898d
7
- data.tar.gz: d7bbf67ba09b13516d3e02536eb1b20a9a7a40b484aca5c468386c8e03ededb478d98acf9d66f0b27f4e3be2e4d577691315359ee9a2d688466e879639d07aa4
6
+ metadata.gz: df4e8f09e3a1e0a54078bae22a4877369126b5774fe471e1d4171a44a400bcee55e14aab58590b16da597a59a3a46935bbd2b0e2cba23e46b247108a2749bd42
7
+ data.tar.gz: 619e7bac2f07d7dc11d4b1a6a2a1933ee7867b2e0237968ddffbdc476dc844da4d726a5005202a7f2ceed1a22ae3a3a8db3c3ffce56bc243e78fc999a858d142
data/README.md CHANGED
@@ -2,22 +2,28 @@
2
2
 
3
3
  ## Most recent changes
4
4
 
5
+ ### v0.1.9.1
6
+
7
+ * Adopting the amazing_print fork of awesome_print for development. Its not used in the main gem, just I like to use it while developing. Doesn't everyone?
8
+
9
+ ### v0.1.9
10
+
11
+ * Changed gemspec to use slop ~> 4.6
12
+
13
+ ### v0.1.8
14
+
15
+ * Changed #get_pathnames_from to issue warnings in place of errors for files that do not have the correct file extension
16
+ * Added some more comments to the code
17
+
5
18
  ### v0.1.3
6
19
 
7
20
  * added ability to process a directory of config files
8
21
  * added ability to process a default set of config files that could get over-written by specific config files specified on the command line
9
22
 
10
- ### v0.1.2
11
-
12
- * replaced the parseconfig gem with the inifile gem -- this now enables the use of ERB in *.ini and *.txt config files
13
- * changed support_config_files to enable_config_files -- cpmsisten terminology
14
23
 
15
24
  ## Description
16
25
 
17
- If you write lots of command-line utility programs, or
18
- even if you don't the cli_helper gem can be a helper
19
- to you. It integrates several common gems to give
20
- a comprehensive configuration management experience.
26
+ If you write lots of command-line utility programs, or even if you don't the cli_helper gem can be a helper to you. It integrates several common gems to give a comprehensive configuration management experience.
21
27
 
22
28
  Here are the gems used and what they do:
23
29
 
@@ -40,48 +46,35 @@ Here are the gems used and what they do:
40
46
 
41
47
  ## Convention
42
48
 
43
- The convention w/r/t what value amoung concurrent sources
44
- is the correct one to use is hierarchic
45
- where the layer above trumps all the layers below. This is the order:
49
+ The convention w/r/t what value amoung concurrent sources is the correct one to use is hierarchic where the layer above trumps all the layers below. This is the order:
46
50
 
47
51
  * command-line parameter
48
52
  * config file value
49
53
  * system environment variable
50
54
  * default
51
55
 
52
- This ordering says that regardless what you have set in
53
- a config file or ENV or as a default, the value of the
54
- command line parameter will be used.
56
+ This ordering says that regardless what you have set in a config file or ENV or as a default, the value of the command line parameter will be used.
55
57
 
56
- I like to use ERB within my config files. Consider 'default.yml.erb'
57
- below:
58
+ I like to use ERB within my config files. Consider 'default.yml.erb' below:
58
59
 
59
60
  ```ruby
60
61
  ---
61
62
  host: <%= Nenv.host || 'localhost' %>
62
63
  ```
63
64
 
64
- Processing this file will give me either the default value for host
65
- of 'localhost' or if defined the value of the system environment
66
- variable HOST. I like Nenv over ENV.
65
+ Processing this file will give me either the default value for host of 'localhost' or if defined the value of the system environment variable HOST. I like Nenv over ENV.
67
66
 
68
- Now suppose I use cli_helper within a program and execute the
69
- program like this:
67
+ Now suppose I use cli_helper within a program and execute the program like this:
70
68
 
71
69
  ```ruby
72
70
  program.rb --host devhost --config default.yml.erb,prod.ini
73
71
  ```
74
72
 
75
- Because I have specifically called out the value of host on the
76
- command line, that value will trump anything that comes from the
77
- config file.
73
+ Because I have specifically called out the value of host on the command line, that value will trump anything that comes from the config file.
78
74
 
79
75
  Did you notice that I had two files specified with the --config option?
80
76
 
81
- The config files are processed in the order that they are given on the command
82
- line. Whatever values were obtained from the first file will be over-written
83
- by the second and any subsequent config files. Regardless of their
84
- values for host, the command-line value trumps them all.
77
+ The config files are processed in the order that they are given on the command line. Whatever values were obtained from the first file will be over-written by the second and any subsequent config files. Regardless of their values for host, the command-line value trumps them all.
85
78
 
86
79
 
87
80
  ## Config files
@@ -98,15 +91,12 @@ cli_helper supports multiple types of configuration files:
98
91
  *.yml.erb
99
92
  ```
100
93
 
101
- All values obtained from config files and command line parameters are
102
- held in the configatron structure.
94
+ All values obtained from config files and command line parameters are held in the configatron structure.
103
95
 
104
96
 
105
97
  ## Common Command-line Options
106
98
 
107
- cli_helper predefines common command-line options. These
108
- can to disabled by the program if necessary. The common options
109
- are:
99
+ cli_helper predefines common command-line options. These can to disabled by the program if necessary. The common options are:
110
100
 
111
101
  ```text
112
102
  -h, --help
@@ -116,33 +106,26 @@ are:
116
106
  --config (optional)
117
107
  ```
118
108
 
119
- To enable the support for config files do this before
120
- calling the #cli_helger() method:
109
+ To enable the support for config files do this before calling the #cli_helger() method:
121
110
 
122
111
  ```ruby
123
112
  configatron.enable_config_files = true
124
113
  ```
125
114
 
126
- To disable any of the other common options do this before
127
- involking cli_helper:
115
+ To disable any of the other common options do this before involking cli_helper:
128
116
 
129
117
  ```ruby
130
- configatron.disable_help = true
131
- configatron.disable_debug = true
118
+ configatron.disable_help = true
119
+ configatron.disable_debug = true
132
120
  configatron.disable_verbose = true
133
121
  cpnfogatrpm/dosab;e_version = true
134
122
  ```
135
123
 
136
124
  ## Other options
137
125
 
138
- The default behavior is to raise an exception if an unspecified option is
139
- used on the command line. For example if your program just uses the common
140
- options and someone invokes the program with --xyzzy then an exception will be
141
- raised saying that the option is unknown.
126
+ The default behavior is to raise an exception if an unspecified option is used on the command line. For example if your program just uses the common options and someone invokes the program with --xyzzy then an exception will be raised saying that the option is unknown.
142
127
 
143
- To prevent this exception you can set the suppress_errors parameter. With
144
- this parameter set to true an unknown option will just be added to the unprocessed
145
- arguments array.
128
+ To prevent this exception you can set the suppress_errors parameter. With this parameter set to true an unknown option will just be added to the unprocessed arguments array.
146
129
 
147
130
  ```ruby
148
131
  configatron.suppress_errors = true
@@ -154,18 +137,15 @@ The unprocessed options can be access via the arguments array:
154
137
  configatron.arguments
155
138
  ```
156
139
 
157
- The arguments array is also where you will find anything else from the
158
- command line that was not processed by the cli_helper. For example:
140
+ The arguments array is also where you will find anything else from the command line that was not processed by the cli_helper. For example:
159
141
 
160
142
  ```ruby
161
143
  my_program.rb -v *.txt
162
144
  ```
163
145
 
164
- The file names matching the '*.txt' glob will be put into the configatron.arguments
165
- array.
146
+ The file names matching the '*.txt' glob will be put into the configatron.arguments array.
166
147
 
167
- When process INI or TXT config files the following options can
168
- be useful:
148
+ When process INI or TXT config files the following options can be useful:
169
149
 
170
150
  ```ruby
171
151
  configatron.ini_comment # default: '#'
@@ -176,9 +156,7 @@ configatron.ini_seperator # default: '='
176
156
 
177
157
  ## Boolean options auto-generate methods
178
158
 
179
- Any boolean command-line option specified, even the predefined common ones,
180
- have two methods defined: query(?) and banger(!). For the help options
181
- the methods look like this:
159
+ Any boolean command-line option specified, even the predefined common ones, have two methods defined: query(?) and banger(!). For the help options the methods look like this:
182
160
 
183
161
  ```ruby
184
162
  def help?
@@ -192,31 +170,20 @@ end
192
170
 
193
171
  ## Names of command-line options
194
172
 
195
- If you specify a command-line option of xyzzy, then an
196
- entry in the configatron structure will be created having the
197
- name 'xyzzy'. If you do not use a long-form for the option
198
- the short option name will be used. For example '-x' will
199
- be accessed as configatron.x
173
+ If you specify a command-line option of xyzzy, then an entry in the configatron structure will be created having the name 'xyzzy'. If you do not use a long-form for the option the short option name will be used. For example '-x' will be accessed as configatron.x
200
174
 
201
175
 
202
176
  ## Support methods
203
177
 
204
- There are several support methods that I have included in cli_helper
205
- that you may want to use. The first three deal with
206
- errors and warnings and what to do with them.
178
+ There are several support methods that I have included in cli_helper that you may want to use. The first three deal with errors and warnings and what to do with them.
207
179
 
208
180
  * warning(a_string)
209
181
  * error(a_string)
210
182
  * abort_if_errors
211
183
 
212
- cli_helper defines two arrays within configatron: errors and warnings. The
213
- warning() and error() methods insert their strings into these arrays. The
214
- abort_if_errors method first looks at the warnings array and presents all of
215
- those strings to the user via STDOUT. It then asks the user if they want
216
- to abort the program. The default answer is no.
184
+ cli_helper defines two arrays within configatron: errors and warnings. The warning() and error() methods insert their strings into these arrays. The abort_if_errors method first looks at the warnings array and presents all of those strings to the user via STDOUT. It then asks the user if they want to abort the program. The default answer is no.
217
185
 
218
- After presenting the warnings to the user, the abort_if_error method presents
219
- all of the errors to the user. Then it exits the program.
186
+ After presenting the warnings to the user, the abort_if_error method presents all of the errors to the user. Then it exits the program.
220
187
 
221
188
  These next support methods are self explanatory:
222
189
 
@@ -229,11 +196,7 @@ But this one needs some explaining:
229
196
 
230
197
  * get_pathnames_from(an_array, extnames=['.json', '.txt', '.docx'])
231
198
 
232
- The method get_pathnames_from() returns an array of pathnames matching a specific
233
- set of file types. The default types are txt, json and docx because that tends to
234
- be the majority of the files in which I am interested. Might add wcml to the default list
235
- later. Regardless you propabily ought to provide your own array of file extensions. And
236
- don't forget the dot!
199
+ The method get_pathnames_from() returns an array of pathnames matching a specific set of file types. The default types are txt, json and docx because that tends to be the majority of the files in which I am interested. Might add wcml to the default list later. Regardless you propabily ought to provide your own array of file extensions. And don't forget the dot!
237
200
 
238
201
  If an entry in the array is a directory then its children will be search including any sub-directories recursively.
239
202
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "cli_helper"
7
- spec.version = '0.1.8'
7
+ spec.version = '0.1.9.1'
8
8
  spec.authors = ["Dewayne VanHoozer"]
9
9
  spec.email = ["dvanhoozer@gmail.com"]
10
10
 
@@ -31,12 +31,12 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency 'configatron'
32
32
  spec.add_dependency 'nenv'
33
33
  spec.add_dependency 'inifile'
34
- spec.add_dependency 'slop', "~> 4.2"
34
+ spec.add_dependency 'slop', "~> 4.6"
35
35
 
36
- spec.add_development_dependency "bundler"
37
- spec.add_development_dependency "rake"
36
+ spec.add_development_dependency 'bundler'
37
+ spec.add_development_dependency 'rake'
38
38
  spec.add_development_dependency 'kick_the_tires'
39
- spec.add_development_dependency 'awesome_print'
39
+ spec.add_development_dependency 'amazing_print'
40
40
  spec.add_development_dependency 'debug_me'
41
41
  spec.add_development_dependency 'timecop'
42
42
 
@@ -10,12 +10,12 @@
10
10
  require 'debug_me'
11
11
  include DebugMe
12
12
 
13
- require 'awesome_print'
13
+ require 'amazing_print'
14
14
 
15
15
  require '../lib/cli_helper'
16
16
  include CliHelper
17
17
 
18
- configatron.version = '0.0.3' # the version of this utility program
18
+ configatron.version = '0.1.9' # the version of this utility program
19
19
  configatron.enable_config_files = false # default is false
20
20
  configatron.disable_help = false # default is false set true to remove the option
21
21
  configatron.disable_verbose = false # ditto
@@ -108,7 +108,7 @@ cli_helper("An example use of cli_helper") do |o|
108
108
  o.string '-s', '--string', 'example string parameter', default: 'IamDefault'
109
109
  o.string '-r', '--required', 'a required parameter' # I know its required because there is no default
110
110
  o.bool '--xyzzy', 'a required boolean without a default', required: true
111
-
111
+
112
112
  # NOTE: you can use many "flags" in defining an option. Each is valid on the command line.
113
113
  # However, only the last flag can be used to retrieve the value via the configatron capability.
114
114
  # To get the value entered by the user for this integer parameter you must use:
@@ -120,7 +120,7 @@ cli_helper("An example use of cli_helper") do |o|
120
120
  o.float '-f', '--float', 'example float parameter', default: (22.0 / 7.0)
121
121
  o.array '-a', '--array', 'example array parameter', default: [:bob, :carol, :ted, :alice]
122
122
  o.path '-p', '--path', 'example Pathname parameter', default: Pathname.new('default/path/to/file.txt')
123
- o.paths '--paths', 'example Pathnames parameter', delimiter: ',',
123
+ o.paths '--paths', 'example Pathnames parameter', delimiter: ',',
124
124
  default: ['default/path/to/file.txt', 'file2.txt'].map{|f| Pathname.new f}
125
125
 
126
126
  o.string '-n', '--name', 'print Hello <name>', default: 'World!', suppress_errors: true do |a_string|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2020-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: configatron
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.2'
61
+ version: '4.6'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.2'
68
+ version: '4.6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: awesome_print
112
+ name: amazing_print
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -200,10 +200,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  requirements: []
203
- rubyforge_project:
204
- rubygems_version: 2.6.4
203
+ rubygems_version: 3.1.3
205
204
  signing_key:
206
205
  specification_version: 4
207
206
  summary: An encapsulation of an integration of slop, nenv, inifile and configatron.
208
207
  test_files: []
209
- has_rdoc: