markdown_exec 1.3.2 → 1.3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -11
- data/CHANGELOG.md +40 -3
- data/Gemfile +6 -3
- data/Gemfile.lock +112 -34
- data/README.md +5 -84
- data/Rakefile +105 -28
- data/bin/tab_completion.sh +2 -2
- data/lib/cached_nested_file_reader.rb +115 -0
- data/lib/colorize.rb +4 -0
- data/lib/env.rb +1 -0
- data/lib/env_opts.rb +54 -56
- data/lib/environment_opt_parse.rb +24 -19
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +589 -260
- data/lib/menu.yml +70 -4
- data/lib/object_present.rb +44 -0
- data/lib/rspec_helpers.rb +10 -0
- data/lib/tap.rb +51 -7
- metadata +4 -4
- data/lib/globfiles.rb +0 -40
- data/lib/yaml_env_opts.rb +0 -60
@@ -31,18 +31,9 @@ class EnvironmentOptParse
|
|
31
31
|
def menu_all(menu_data, lambdas, config)
|
32
32
|
config.tap_yaml 'config'
|
33
33
|
input_option_values, remainder, = menu_parse(add_proc(menu_data, lambdas))
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# options = menu_data.map do |menu_item|
|
38
|
-
# menu_item.tap_inspect 'menu_item'
|
39
|
-
# mion = menu_item[:opt_name]&.to_sym.tap_inspect 'mion'
|
40
|
-
# omion = config[mion].tap_inspect 'omion'
|
41
|
-
# unless omion.nil?
|
42
|
-
# menu_item[:default] = omion
|
43
|
-
# end
|
44
|
-
# menu_item
|
45
|
-
# end,
|
34
|
+
options = menu_default_option_values(menu_data)
|
35
|
+
.merge(config)
|
36
|
+
.merge(input_option_values)
|
46
37
|
|
47
38
|
[options, remainder]
|
48
39
|
end
|
@@ -53,7 +44,8 @@ class EnvironmentOptParse
|
|
53
44
|
procname = menu_item[:procname]
|
54
45
|
next if procname.nil?
|
55
46
|
|
56
|
-
menu_item[:proccode] =
|
47
|
+
menu_item[:proccode] =
|
48
|
+
lambdas.fetch(procname.to_sym, menu_item[:procname])
|
57
49
|
end.tap_yaml
|
58
50
|
end
|
59
51
|
|
@@ -89,15 +81,21 @@ class EnvironmentOptParse
|
|
89
81
|
mmoo = [
|
90
82
|
# long name
|
91
83
|
if item[:long_name].present?
|
92
|
-
"--#{item[:long_name]}#{item[:arg_name].present?
|
84
|
+
# if "--#{item[:long_name]}#{item[:arg_name]".present?
|
85
|
+
# " #{item[:arg_name]}"
|
86
|
+
# else
|
87
|
+
# "''}"
|
88
|
+
# end
|
93
89
|
end,
|
94
90
|
|
95
91
|
# short name
|
96
92
|
item[:short_name].present? ? "-#{item[:short_name]}" : nil,
|
97
93
|
|
98
94
|
# description and default
|
99
|
-
[
|
100
|
-
|
95
|
+
[
|
96
|
+
item[:description],
|
97
|
+
item[:default].present? ? "[#{value_for_menu item[:default]}]" : nil
|
98
|
+
].compact.join(' '),
|
101
99
|
|
102
100
|
# apply proccode, if present, to value
|
103
101
|
# save value to options hash if option is named
|
@@ -122,7 +120,10 @@ class EnvironmentOptParse
|
|
122
120
|
menu_option_append opts, options, item
|
123
121
|
end
|
124
122
|
end
|
125
|
-
|
123
|
+
|
124
|
+
# filename defaults to basename of the program
|
125
|
+
# without suffix in a directory ~/.options
|
126
|
+
option_parser.load
|
126
127
|
option_parser.environment # env defaults to the basename of the program.
|
127
128
|
remainder = option_parser.parse!
|
128
129
|
|
@@ -184,12 +185,16 @@ class EnvironmentOptParse
|
|
184
185
|
# lambda { |v| options.tap_puts 'eop_l' }
|
185
186
|
# }).call(@options),
|
186
187
|
|
187
|
-
stdout_defaults:
|
188
|
+
stdout_defaults: lambda { |_|
|
189
|
+
menu_default_option_values(@menu).to_yaml.tap_puts
|
190
|
+
},
|
188
191
|
stdout_help: lambda { |_|
|
189
192
|
menu_help(@menu).tap_puts
|
190
193
|
exit
|
191
194
|
},
|
192
|
-
val_as_bool:
|
195
|
+
val_as_bool: lambda { |value|
|
196
|
+
value.class.to_s == 'String' ? (value.chomp != '0') : value
|
197
|
+
},
|
193
198
|
val_as_int: ->(value) { value.to_i },
|
194
199
|
val_as_str: ->(value) { value.to_s },
|
195
200
|
version: lambda { |_|
|