aro 0.1.7 → 0.1.9

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/aro.gemspec +3 -3
  3. data/bin/aos +24 -0
  4. data/bin/aro +5 -2
  5. data/checksums/aro-0.1.7.gem.sha512 +1 -0
  6. data/checksums/aro-0.1.8.gem.sha512 +1 -0
  7. data/checksums/aro-0.1.9.gem.sha512 +1 -0
  8. data/db/migrate/1763374647_create_decks.rb +5 -2
  9. data/db/migrate/1763432541_create_logs.rb +1 -0
  10. data/db/migrate/1765148774_create_yous.rb +19 -0
  11. data/listen.rb +1 -1
  12. data/locale/en.aos.yml +31 -0
  13. data/locale/en.cngelog.yml +5 -0
  14. data/locale/en.dom.yml +42 -0
  15. data/locale/en.usage.yml +23 -13
  16. data/locale/en.yml +43 -34
  17. data/sys/aos/aos.rb +282 -0
  18. data/sys/aos/db.rb +80 -0
  19. data/sys/aos/s.rb +25 -0
  20. data/sys/aos/views/base.rb +155 -0
  21. data/sys/aos/views/dom.rb +36 -0
  22. data/sys/aos/views/games/abpps.rb +21 -0
  23. data/sys/aos/views/games/game.rb +114 -0
  24. data/sys/aos/views/games/hbpps.rb +21 -0
  25. data/sys/aos/views/games/shpps.rb +21 -0
  26. data/sys/aos/views/games/vipps.rb +21 -0
  27. data/sys/aos/views/games.rb +19 -0
  28. data/sys/aos/views/know/library.rb +19 -0
  29. data/sys/aos/views/know/temple.rb +19 -0
  30. data/sys/aos/views/know.rb +19 -0
  31. data/sys/aos/views/setup/settings.rb +37 -0
  32. data/sys/aos/views/setup.rb +19 -0
  33. data/sys/aos/views/welcome/waite.rb +19 -0
  34. data/sys/aos/views/welcome/winner.rb +19 -0
  35. data/sys/aos/views/welcome.rb +19 -0
  36. data/sys/aos/you.rb +19 -0
  37. data/sys/aro/d.rb +1 -1
  38. data/sys/aro/db.rb +5 -13
  39. data/sys/aro/mancy.rb +23 -19
  40. data/sys/aro/p.rb +2 -2
  41. data/sys/aro/v.rb +2 -3
  42. data/sys/aro.rb +1 -0
  43. data/sys/cli/config.rb +244 -123
  44. data/sys/cli/constants.rb +8 -5
  45. data/sys/cli/deck.rb +13 -8
  46. data/sys/cli/dom.rb +16 -17
  47. data/sys/cli/nterface.rb +6 -0
  48. data/sys/dom/d.rb +24 -19
  49. data/sys/dom/dom.rb +74 -96
  50. data/sys/dom/p.rb +1 -1
  51. data/sys/models/deck.rb +23 -13
  52. data/sys/models/log.rb +12 -2
  53. data/sys/reiquire.rb +3 -2
  54. data/sys/shr/prompt.rb +12 -4
  55. data/sys/shr/t.rb +12 -10
  56. data/sys/shr/version.rb +4 -4
  57. metadata +52 -27
  58. data/sys/views/base.rb +0 -29
  59. data/sys/views/dom.rb +0 -27
  60. data/sys/views/games/deck.rb +0 -97
  61. data/sys/views/games/menu.rb +0 -27
  62. data/sys/views/setup/setup.rb +0 -27
data/sys/cli/config.rb CHANGED
@@ -12,7 +12,7 @@ module CLI
12
12
 
13
13
  # cli entrypoint
14
14
  def self.config
15
- Aro::D.say("#{__FILE__}:#{__method__} was called (todo)...")
15
+ CLI::Config.process_config_command(ARGV)
16
16
  end
17
17
 
18
18
  class Config
@@ -53,41 +53,76 @@ module CLI
53
53
  RUBY_FACOT: :ruby_facot,
54
54
  }
55
55
 
56
+ # ovar and ivar access
57
+ #
58
+ # example usage:
59
+ # CLI::Config::DEF_ACCESS[:READ]
56
60
  DEF_ACCESS = {
57
61
  READ: :read,
58
62
  WRITE: :write
59
63
  }
60
64
 
65
+ BOOLS = {
66
+ FALSE: false,
67
+ TRUE: true,
68
+ }
69
+
70
+ TYPES = {
71
+ BOOL: :bool,
72
+ INT: :int,
73
+ STRING: :string,
74
+ VALUES: :values
75
+ }
76
+
61
77
  # types used in definition
62
78
  #
63
79
  # example usage:
64
80
  # CLI::Config::DEF_TYPES[:INT][:validator].call(unvalid, CLI::Config::DEF[:DIMENSION])
65
81
  DEF_TYPES = {
82
+ BOOL: {
83
+ name: CLI::Config::TYPES[:BOOL],
84
+ description: I18n.t("cli.config.type.bool_description"),
85
+ converter: Proc.new{|v|
86
+ if [CLI::Config::BOOLS[:TRUE].to_s, Aro::Mancy::S].include?(v)
87
+ CLI::Config::BOOLS[:TRUE]
88
+ else
89
+ CLI::Config::BOOLS[:FALSE]
90
+ end
91
+ },
92
+ validator: Proc.new{|unvalid, k, v|
93
+ CLI::Config.def_valid?(k, v) &&
94
+ CLI::Config.bool_valid?(unvalid)
95
+ }
96
+ },
66
97
  INT: {
67
98
  name: :int,
68
- description: I18n.t("cli.config.type_int_description"),
99
+ description: I18n.t("cli.config.type.int_description"),
100
+ converter: Proc.new{|v| v.to_i},
69
101
  validator: Proc.new{|unvalid, k, v|
102
+ Aro::V.say("validating #{k} (#{CLI::Config::DEF_TYPES[:INT][:name]})")
103
+ Aro::V.say("unvalid = #{unvalid}")
104
+ Aro::V.say("[min, max] = [#{v[:min]}, #{v[:max]}]")
70
105
  int_valid = CLI::Config.def_valid?(k, v) &&
71
106
  CLI::Config.int_valid?(unvalid) &&
72
107
  unvalid.to_i >= v[:min] &&
73
108
  unvalid.to_i <= v[:max]
74
-
75
- Aro::V.say("validating #{k} (#{CLI::Config::DEF_TYPES[:INT][:name]})")
76
- Aro::V.say("unvalid = #{unvalid}")
77
- Aro::V.say("unvalid is#{int_valid ? " " : :" not ".to_s}valid.")
109
+ Aro::V.say("unvalid(#{unvalid}) is#{int_valid ? " " : :" not ".to_s}valid.")
78
110
  int_valid
79
111
  }
80
112
  },
81
113
  STRING: {
82
114
  name: :string,
83
- description: I18n.t("cli.config.type_string_description"),
115
+ description: I18n.t("cli.config.type.string_description"),
116
+ converter: Proc.new{|v| v.to_s},
84
117
  validator: Proc.new{|unvalid, k, v|
85
- unvalid.is_a?(String)
118
+ CLI::Config.def_valid?(k, v) &&
119
+ CLI::Config.string_valid?(unvalid)
86
120
  }
87
121
  },
88
122
  VALUES: {
89
123
  name: :values,
90
- description: I18n.t("cli.config.type_values_description"),
124
+ description: I18n.t("cli.config.type.values_description"),
125
+ converter: Proc.new{|v| v.to_s},
91
126
  validator: Proc.new{|unvalid, k, v|
92
127
  CLI::Config.def_valid?(k, v) &&
93
128
  v[:possible_values].keys.include?(unvalid&.to_sym)
@@ -95,10 +130,18 @@ module CLI
95
130
  },
96
131
  }
97
132
 
133
+ def self.bool_valid?(unvalid)
134
+ CLI::Config::BOOLS.values.map{|b| b.to_s.to_sym}.include?(unvalid&.to_s&.to_sym)
135
+ end
136
+
98
137
  def self.int_valid?(unvalid)
99
138
  !unvalid&.to_i.nil?
100
139
  end
101
140
 
141
+ def self.string_valid?(unvalid)
142
+ unvalid.is_a?(String)
143
+ end
144
+
102
145
  def self.def_valid?(key, deff)
103
146
  def_valid = deff == CLI::Config::DEF[key]
104
147
  unless def_valid
@@ -109,80 +152,106 @@ module CLI
109
152
  end
110
153
 
111
154
  def validate_config
112
- invalid_defs = []
113
- CLI::Config::DEF.each{|k, v|
114
- invalid_defs << k unless validate_value(CLI::Config.ivar(k), k, v)
155
+ invalid_vars = []
156
+ CLI::Config::DEF.each{|k, v|
157
+ Aro::V.say(v[:access])
158
+ is_valid = v[:access] == CLI::Config::DEF_ACCESS[:READ]
159
+ unless is_valid
160
+ is_valid = valid_var?(CLI::Config.ivar(k), k, v)
161
+ end
162
+ invalid_vars << k unless is_valid
115
163
  }
116
- invalid_defs
164
+ invalid_vars
117
165
  end
118
166
 
119
- def validate_value(var_value, k, v)
167
+ def valid_var?(var_value, k, v)
168
+ Aro::V.say(v)
169
+ return true if v[:access] == CLI::Config::DEF_ACCESS[:READ]
170
+
120
171
  CLI::Config::DEF_TYPES[
121
172
  v[:type].to_s.upcase.to_sym
122
173
  ][:validator].call(var_value, k, v)
123
- end
174
+ end
175
+
176
+ def convert_var_for_def(k)
177
+ CLI::Config::DEF_TYPES[
178
+ CLI::Config::DEF[k][:type].upcase
179
+ ][:converter].call(ENV[CLI::Config.ivar_k(k)])
180
+ end
124
181
 
125
182
  # adapts I18n translations to generate bash environment vars.
126
183
  #
127
184
  # example usage:
128
185
  # CLI::Config::DEF[:Z_MAX]
129
186
  DEF = {
130
- # writable variables
187
+
188
+ #
189
+ # => ivars
190
+ #
131
191
  ENV: {
132
- type: :values,
192
+ type: CLI::Config::TYPES[:VALUES],
133
193
  access: CLI::Config::DEF_ACCESS[:WRITE],
134
194
  value: CLI::Config::ENVS[:PRODUCTION],
135
- description: I18n.t(
136
- "cli.config.env_description",
137
- possible_values: CLI::Config::ENVS.values.join(", ")
138
- ),
195
+ description: I18n.t("cli.config.env.description"),
139
196
  possible_values: {
140
- development: I18n.t("cli.config.env_development_description"),
141
- production: I18n.t("cli.config.env_production_description"),
142
- test: I18n.t("cli.config.env_test_description"),
197
+ development: I18n.t("cli.config.env.development_description"),
198
+ production: I18n.t("cli.config.env.production_description"),
199
+ test: I18n.t("cli.config.env.test_description"),
143
200
  }
144
201
  },
202
+ VERBOSE: {
203
+ type: CLI::Config::TYPES[:BOOL],
204
+ access: CLI::Config::DEF_ACCESS[:WRITE],
205
+ value: CLI::Config::BOOLS[:FALSE],
206
+ description: I18n.t("cli.config.verbose_description"),
207
+ },
145
208
  FORMAT: { # not implemented yet.
146
- type: :values,
209
+ type: CLI::Config::TYPES[:VALUES],
147
210
  implemented: false,
148
211
  access: CLI::Config::DEF_ACCESS[:WRITE],
149
212
  value: CLI::Config::FORMATS[:TEXT],
150
- description: I18n.t(
151
- "cli.config.format_description",
152
- possible_values: CLI::Config::FORMATS.values.join(", ")
153
- ),
213
+ description: I18n.t("cli.config.format.description"),
154
214
  possible_values: {
155
- text: I18n.t("cli.config.text_format_description"),
156
- json: I18n.t("cli.config.json_format_description")
215
+ text: I18n.t("cli.config.format.text_description"),
216
+ json: I18n.t("cli.config.format.json_description")
157
217
  }
158
218
  },
159
219
  DIMENSION: {
160
- type: :values,
220
+ type: CLI::Config::TYPES[:VALUES],
161
221
  access: CLI::Config::DEF_ACCESS[:WRITE],
162
222
  value: CLI::Config::DMS[:DEV_TAROT],
163
- description: I18n.t(
164
- "cli.config.dimension_description",
165
- possible_values: CLI::Config::DMS.values.join(", ")
166
- ),
223
+ description: I18n.t("cli.config.dimension.description"),
167
224
  possible_values: {
168
- dev_tarot: I18n.t("cli.config.dimension_dev_tarot_description"),
169
- ruby_facot: I18n.t("cli.config.dimension_ruby_facot_description"),
225
+ dev_tarot: I18n.t("cli.config.dimension.dev_tarot_description"),
226
+ ruby_facot: I18n.t("cli.config.dimension.ruby_facot_description"),
170
227
  }
171
228
  },
172
- DISPLAY_COLUMNS: {
173
- type: :int,
229
+ HEIGHT: {
230
+ type: CLI::Config::TYPES[:INT],
174
231
  access: CLI::Config::DEF_ACCESS[:WRITE],
175
- value: Aro::Mancy::NUMERALS[:VII],
232
+ value: Aro::Mancy::NUMERALS[:XLII],
233
+ min: Aro::Mancy::NUMERALS[:I],
234
+ max: Aro::Mancy::NUMERALS[:MMXCVII],
235
+ description: I18n.t(
236
+ "cli.config.height_description",
237
+ min: Aro::Mancy::NUMERALS[:I],
238
+ max: Aro::Mancy::NUMERALS[:VII].pow(Aro::Mancy::OS),
239
+ ),
240
+ },
241
+ WIDTH: {
242
+ type: CLI::Config::TYPES[:INT],
243
+ access: CLI::Config::DEF_ACCESS[:WRITE],
244
+ value: Aro::Mancy::NUMERALS[:C] + Aro::Mancy::NUMERALS[:XXXVII] - Aro::Mancy::S,
176
245
  min: Aro::Mancy::NUMERALS[:I],
177
- max: Aro::Mancy::NUMERALS[:XXII] / Aro::Mancy::OS,
246
+ max: Aro::Mancy::NUMERALS[:MMXCVII],
178
247
  description: I18n.t(
179
- "cli.config.display_columns_description",
248
+ "cli.config.width_description",
180
249
  min: Aro::Mancy::NUMERALS[:I],
181
- max: Aro::Mancy::NUMERALS[:XXII] / Aro::Mancy::OS,
250
+ max: Aro::Mancy::NUMERALS[:XI].pow(Aro::Mancy::OS),
182
251
  ),
183
252
  },
184
253
  Z: {
185
- type: :int,
254
+ type: CLI::Config::TYPES[:INT],
186
255
  access: CLI::Config::DEF_ACCESS[:WRITE],
187
256
  value: Aro::Mancy::NUMERALS[:I],
188
257
  min: Aro::Mancy::NUMERALS[:I],
@@ -194,7 +263,7 @@ module CLI
194
263
  ),
195
264
  },
196
265
  Z_MAX: {
197
- type: :int,
266
+ type: CLI::Config::TYPES[:INT],
198
267
  access: CLI::Config::DEF_ACCESS[:WRITE],
199
268
  value: Aro::Mancy::NUMERALS[:VII],
200
269
  min: Aro::Mancy::NUMERALS[:I],
@@ -206,78 +275,81 @@ module CLI
206
275
  ),
207
276
  },
208
277
 
209
- # read only variables
278
+ #
279
+ # => ovars
280
+ #
210
281
  ARO_ENV_O: {
211
- type: :string,
282
+ type: CLI::Config::TYPES[:INT],
212
283
  access: CLI::Config::DEF_ACCESS[:READ],
213
284
  value: Aro::Mancy::O,
214
- description: I18n.t(
215
- "cli.config.aro_env_O_description"
216
- ),
285
+ description: I18n.t("cli.config.aro_env.O_description"),
217
286
  },
218
287
  ARO_ENV_S: {
219
- type: :string,
288
+ type: CLI::Config::TYPES[:INT],
220
289
  access: CLI::Config::DEF_ACCESS[:READ],
221
290
  value: Aro::Mancy::S,
222
- description: I18n.t(
223
- "cli.config.aro_env_S_description"
224
- ),
291
+ description: I18n.t("cli.config.aro_env.S_description"),
225
292
  },
226
293
  ARO_ENV_OS: {
227
- type: :string,
294
+ type: CLI::Config::TYPES[:INT],
228
295
  access: CLI::Config::DEF_ACCESS[:READ],
229
296
  value: Aro::Mancy::OS,
230
- description: I18n.t(
231
- "cli.config.aro_env_OS_description"
232
- ),
297
+ description: I18n.t("cli.config.aro_env.OS_description"),
298
+ },
299
+ ARO_ENV_E: {
300
+ type: CLI::Config::TYPES[:INT],
301
+ access: CLI::Config::DEF_ACCESS[:READ],
302
+ value: Aro::Mancy::E,
303
+ description: I18n.t("cli.config.aro_env.E_description"),
233
304
  },
234
305
  ARO_ENV_N: {
235
- type: :string,
306
+ type: CLI::Config::TYPES[:INT],
236
307
  access: CLI::Config::DEF_ACCESS[:READ],
237
308
  value: Aro::Mancy::N,
238
- description: I18n.t(
239
- "cli.config.aro_env_N_description"
240
- ),
309
+ description: I18n.t("cli.config.aro_env.N_description"),
241
310
  },
242
311
  ARO_ENV_PS1: {
243
- type: :string,
312
+ type: CLI::Config::TYPES[:STRING],
244
313
  access: CLI::Config::DEF_ACCESS[:READ],
245
314
  value: Aro::Mancy::PS1,
246
- description: I18n.t(
247
- "cli.config.aro_env_PS1_description"
248
- ),
315
+ description: I18n.t("cli.config.aro_env.PS1_description"),
249
316
  },
250
317
  ARO_ENV_NAME_FILE: {
251
- type: :string,
318
+ type: CLI::Config::TYPES[:STRING],
252
319
  access: CLI::Config::DEF_ACCESS[:READ],
253
320
  value: Aro::Mancy::NAME_FILE,
254
- description: I18n.t(
255
- "cli.config.aro_env_NAME_FILE_description"
256
- ),
321
+ description: I18n.t("cli.config.aro_env.NAME_FILE_description"),
257
322
  },
258
323
  ARO_ENV_I2097I: {
259
- type: :string,
324
+ type: CLI::Config::TYPES[:STRING],
260
325
  access: CLI::Config::DEF_ACCESS[:READ],
261
- description: I18n.t(
262
- "cli.config.aro_env_I2097I_description"
263
- ),
264
- value: Aro::Mancy::I2097I
326
+ value: Aro::Mancy::I2097I,
327
+ description: I18n.t("cli.config.aro_env.I2097I_description"),
265
328
  },
266
329
  ARO_ENV_YES: {
267
- type: :string,
330
+ type: CLI::Config::TYPES[:STRING],
268
331
  access: CLI::Config::DEF_ACCESS[:READ],
269
332
  value: Aro::Mancy::YES,
270
- description: I18n.t(
271
- "cli.config.aro_env_YES_description"
272
- ),
333
+ description: I18n.t("cli.config.aro_env.YES_description"),
334
+ },
335
+ ARO_ENV_ALL: {
336
+ type: CLI::Config::TYPES[:STRING],
337
+ access: CLI::Config::DEF_ACCESS[:READ],
338
+ value: Aro::Mancy::ALL,
339
+ description: I18n.t("cli.config.aro_env.ALL_description"),
273
340
  },
274
-
275
- # ...
276
341
  }
277
342
 
278
343
  def initialize
279
- Aro::P.say("config init")
280
- return unless Aro::Mancy.is_aro_space? && Aro::Mancy.is_initialized?
344
+ @@context = nil
345
+ if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
346
+ @@context = Aro::Mancy.name
347
+ elsif Aro::Dom.in_arodom? && Aro::Dom.is_initialized?
348
+ @@context = Aro::Dom.name
349
+ end
350
+
351
+ return if @@context.nil?
352
+
281
353
  unless File.exist?(CLI::Config.config_filepath)
282
354
  generate_config
283
355
  end
@@ -287,33 +359,44 @@ module CLI
287
359
  end
288
360
 
289
361
  def self.config_filepath
290
- File.join(Aro::Db.base_aro_dir, CLI::Config::CONFIG_FILE.to_s)
362
+ db_cls = @@context == Aro::Dom.name ? Aos::Db : Aro::Db
363
+ File.join(db_cls.base_aro_dir, CLI::Config::CONFIG_FILE.to_s)
291
364
  end
292
365
 
293
- def self.display_config
294
- Aro::V.say("getting display config...")
295
- columns = CLI::Config.ivar(:DISPLAY_COLUMNS)
296
- Aro::V.say("DISPLAY_COLUMNS: #{columns}")
297
-
298
- # default
299
- width = CLI::Config::DEF[:DISPLAY_COLUMNS][:value]
300
- if columns.respond_to?(:to_i)
301
- # user setting
302
- columns = columns.to_i
303
- width = columns.to_i.pow(Aro::Mancy::OS)
304
- end
305
- Aro::V.say("WIDTH: #{width}")
366
+ def self.is_test?
367
+ ENV[:ARO_ENV.to_s] == CLI::Config::ENVS[:TEST].to_s
368
+ end
306
369
 
307
- {
370
+ def self.display_config
371
+ # Aro::V.say(__method__)
372
+ width = CLI::Config.ivar(:WIDTH).to_i
373
+ columns = width.pow(Aro::Mancy::S.to_f / Aro::Mancy::OS.to_f).to_i
374
+ result = {
308
375
  COLUMNS: columns,
376
+ HEIGHT: CLI::Config.ivar(:HEIGHT).to_i,
309
377
  WIDTH: width,
310
- DIVIDER: :"-".to_s
378
+ DIVIDER: :"_".to_s
311
379
  }
380
+ # Aro::V.say(result)
381
+
382
+ result
383
+ end
384
+
385
+ def self.process_config_command(args)
386
+ if args[1].nil? || args[1] == :aos.to_s
387
+ # print config
388
+ Aro::P.say((
389
+ ["config loaded from #{CLI::Config.config_filepath}"] +
390
+ CLI::Config.dump_config
391
+ ).join("\n"))
392
+ elsif [args[2],args[3]].compact.any? && args[1] == Aos::Os::CMDS[:CONFIG][:cmds][:SET][:key].to_s
393
+ CLI::Config.set_ivar(args[2], args[3])
394
+ end
312
395
  end
313
396
 
314
397
  # out vars
315
398
  def self.ovar(suffix)
316
- ENV[CLI::Config.ovar_k(suffix)]
399
+ CLI::Config::DEF[suffix][:value]
317
400
  end
318
401
  # out vars
319
402
  def self.ovar_k(suffix)
@@ -329,24 +412,57 @@ module CLI
329
412
  "#{CLI::Config::ARO_CONFIG_PREFIX}#{suffix}"
330
413
  end
331
414
 
415
+ def self.set_ivar(k, new_value)
416
+ k = k.upcase.to_sym
417
+
418
+ current_value = CLI::Config.ivar(k)
419
+ # ensure the var name is valid
420
+ unless current_value.nil?
421
+ Aro::V.say("validating #{k} with value #{new_value}")
422
+ if CLI::Config.instance.valid_var?(new_value, k, CLI::Config::DEF[k])
423
+ # set ENV value
424
+ ENV[CLI::Config.ivar_k(k)] = new_value
425
+ Aro::V.say(ENV[CLI::Config.ivar_k(k)])
426
+
427
+ # flush existing config and regen
428
+ CLI::Config.instance.generate_config(true)
429
+ CLI::Config.instance.source_config
430
+ CLI::Config.instance.setup_env
431
+ else
432
+ Aro::Dom::P.say("the ivar value you entered is invalid. ignoring.")
433
+ end
434
+ else
435
+ Aro::Dom::P.say("the ivar name you entered is invalid. ignoring.")
436
+ end
437
+ end
438
+
332
439
  def setup_env
333
440
  # do not change - update $ARO_CONFIG_ENV .aro/.config file
334
441
  #
335
442
  # default is production
336
443
  varenv = CLI::Config.ivar(:ENV)
337
- var_valid = validate_value(varenv, :ENV, CLI::Config::DEF[:ENV])
338
- ENV[:ARO_ENV.to_s] = var_valid ? varenv : CLI::Config::ENVS[:PRODUCTION].to_s
444
+ is_valid = valid_var?(varenv, :ENV, CLI::Config::DEF[:ENV])
445
+ ENV[:ARO_ENV.to_s] = is_valid ? varenv : CLI::Config::ENVS[:PRODUCTION].to_s
339
446
  Aro::D.say("setup_env: #{ENV[:ARO_ENV.to_s]}")
340
447
  end
341
448
 
342
- def self.is_test?
343
- ENV[:ARO_ENV.to_s] == CLI::Config::ENVS[:TEST].to_s
449
+ def self.dump_config
450
+ dump = []
451
+ CLI::Config::DEF.each{|k, v|
452
+ if v[:access] == CLI::Config::DEF_ACCESS[:WRITE]
453
+ dump << "$#{CLI::Config.ivar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{CLI::Config.ivar(k)}"
454
+ else
455
+ dump << "$#{CLI::Config.ovar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{CLI::Config.ovar(k)}"
456
+ end
457
+ }
458
+
459
+ dump
344
460
  end
345
461
 
346
462
  def source_config
347
- Aro::D.say(I18n.t("cli.config.sourcing_config", name: CLI::Config.config_filepath))
463
+ Aro::D.say(I18n.t("cli.config.source", name: CLI::Config.config_filepath))
348
464
  File.read(CLI::Config.config_filepath).split("\n").select{|line|
349
- line.match?(/export #{:ARO_}/)
465
+ line.match?(/export #{CLI::Config::ARO_CONFIG_PREFIX}/)
350
466
  }.map{|line|
351
467
  line.gsub("export ", "").split("=")
352
468
  }.each{|kv|
@@ -357,19 +473,20 @@ module CLI
357
473
 
358
474
  # todo: implement
359
475
  invalid_defs = validate_config
360
- CLI::Config::DEF.keys.each{|dfk|
361
- Aro::V.say("$#{CLI::Config.ivar_k(dfk)}=#{CLI::Config.ivar(dfk)}")
476
+ CLI::Config.dump_config.each{|l| Aro::V.say(l)}
477
+ invalid_defs.each{|k|
478
+ v = CLI::Config::DEF[k.to_sym]
479
+ if v[:access] == CLI::Config::DEF_ACCESS[:WRITE]
480
+ ENV[CLI::Config.ivar_k(k)] = v[:value]
481
+ else
482
+ ENV[CLI::Config.ovar_k(k)] = v[:value]
483
+ end
362
484
  }
363
- Aro::V.say("todo: invalid_defs: #{invalid_defs}")
364
- # todo: set all invalid_refs to default in ENV
365
- # invalid_defs.each{|id|
366
-
367
- # }
368
485
  end
369
486
 
370
- def generate_config
487
+ def generate_config(from_memory = false)
371
488
  # todo: localize generated config text
372
- Aro::D.say(I18n.t("cli.config.generating_default_config", name: CLI::Config.config_filepath))
489
+ Aro::D.say(I18n.t("cli.config.generate", name: CLI::Config.config_filepath))
373
490
  File.open(CLI::Config.config_filepath, "w+") do |file|
374
491
  # intro
375
492
  Aro::Mancy::OS.times do
@@ -404,7 +521,7 @@ module CLI
404
521
 
405
522
  # vars
406
523
  CLI::Config::DEF.each{|k, v|
407
- print_var file.object_id, k, v
524
+ print_var file.object_id, k, v, (from_memory ? ENV[CLI::Config.ivar_k(k)] : nil)
408
525
  }
409
526
 
410
527
  print_osr file.object_id
@@ -475,7 +592,7 @@ module CLI
475
592
  file.write("# => which can be used to write programs on top of aro.\n")
476
593
  end
477
594
 
478
- def print_var f_object_id, k, v
595
+ def print_var f_object_id, k, v, mem_v
479
596
  file = ObjectSpace._id2ref f_object_id
480
597
 
481
598
  is_ovar = CLI::Config::DEF[k][:access] == CLI::Config::DEF_ACCESS[:READ]
@@ -487,17 +604,17 @@ module CLI
487
604
  Aro::V.say("access for #{k} is #{CLI::Config::DEF[k][:access]}")
488
605
  Aro::V.say("using var_name: #{var_name}")
489
606
  file.write("# [#{var_name}] (#{is_ovar ? :ovar : :ivar})\n")
490
- file.write("# => #{I18n.t("cli.config.def_type")}: #{v[:type]}\n")
607
+ file.write("# => CLI::Config::DEF_TYPES: #{v[:type]}\n")
491
608
  case v[:type]
492
609
  when CLI::Config::DEF_TYPES[:INT][:name]
493
- file.write("# => #{I18n.t("cli.config.type_int_description")}\n")
610
+ file.write("# => #{I18n.t("cli.config.type.int_description")}\n")
494
611
  file.write("# => #{I18n.t("cli.config.minimum")}: #{v[:min]}\n")
495
612
  file.write("# => #{I18n.t("cli.config.maximum")}: #{v[:max]}\n")
496
613
  when CLI::Config::DEF_TYPES[:STRING][:name]
497
- file.write("# => #{I18n.t("cli.config.type_string_description")}\n")
614
+ file.write("# => #{I18n.t("cli.config.type.string_description")}\n")
498
615
  file.write("# => use \"double quotes\" if there are any spaces.\n")
499
616
  when CLI::Config::DEF_TYPES[:VALUES][:name]
500
- file.write("# => #{I18n.t("cli.config.type_values_description")}\n")
617
+ file.write("# => #{I18n.t("cli.config.type.values_description")}\n")
501
618
  file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
502
619
  print_sr f_object_id
503
620
  v[:possible_values].each{|name, description|
@@ -510,7 +627,11 @@ module CLI
510
627
  print_osr f_object_id
511
628
  file.write("# => description:\n")
512
629
  file.write("# => #{v[:description]}\n")
513
- file.write("export #{var_name}=#{v[:value]}\n")
630
+ if is_ovar && CLI::Config::DEF_TYPES[:STRING][:name] == v[:type]
631
+ file.write("export #{var_name}=\"#{v[:value]}\"\n")
632
+ else
633
+ file.write("export #{var_name}=#{mem_v || v[:value]}\n")
634
+ end
514
635
  print_osr f_object_id
515
636
  end
516
637
 
data/sys/cli/constants.rb CHANGED
@@ -18,12 +18,16 @@ module CLI
18
18
  }
19
19
 
20
20
  EXIT_CODES = {
21
- SUCCESS: 0,
22
- GENERAL_ERROR: 1,
23
- INVALID_ARG: 3
21
+ SUCCESS: Aro::Mancy::O,
22
+ GENERAL_ERROR: Aro::Mancy::S,
23
+ INVALID_ARG: Aro::Mancy::E,
24
24
  }
25
25
 
26
26
  CMDS = {
27
+ AOS: {
28
+ RUN: :run,
29
+ WATCH: :watch,
30
+ },
27
31
  ARO: {
28
32
  CREATE: :create,
29
33
  CONFIG: :config,
@@ -45,9 +49,8 @@ module CLI
45
49
  },
46
50
  DOM: {
47
51
  INIT: :init,
48
- MAP: :map,
49
52
  NEW: :new,
50
- }
53
+ },
51
54
  }
52
55
 
53
56
  end
data/sys/cli/deck.rb CHANGED
@@ -13,11 +13,11 @@ module CLI
13
13
  def self.deck
14
14
  action = CLI::ARGV1&.to_sym
15
15
 
16
- if CLI::FLAGS[:HELP].include?(CLI::ARGV1)
16
+ if CLI::FLAGS[:HELP].include?(action.to_s)
17
17
  # todo: breakout usage into subcommand-specific verbiage
18
18
  CLI.usage::usage
19
19
  exit(CLI::EXIT_CODES[:SUCCESS])
20
- elsif CLI::ARGV1.nil?
20
+ elsif action.nil? || action == :aos
21
21
  # no args, open deck menu
22
22
  Aro::Db.new
23
23
  Aro::Deck.display_selection_menu
@@ -51,7 +51,7 @@ module CLI
51
51
  Aro::P.say(I18n.t("cli.messages.replacing_drawn", name: Aro::Mancy.game.name))
52
52
  Aro::Mancy.game.replace
53
53
  when CLI::CMDS[:DECK][:RESET]
54
- if Aro::Mancy::YES.to_s != Aro::P.p.ask(I18n.t("cli.messages.confirmation_prompt", name: Aro::Mancy.game.name))
54
+ if Aro::Mancy::YES.to_s != Aro::P.p.ask("#{Aro::Mancy::PS1}#{I18n.t("cli.messages.confirmation_prompt", name: Aro::Mancy.game.name)}")
55
55
  Aro::P.say(I18n.t("cli.messages.understood", name: Aro::Mancy.game.name))
56
56
  exit(CLI::EXIT_CODES[:SUCCESS])
57
57
  end
@@ -60,6 +60,11 @@ module CLI
60
60
  Aro::Mancy.game.reset
61
61
  end
62
62
 
63
+ if ARGV.include?(:aos.to_s)
64
+ # run silent
65
+ exit(CLI::EXIT_CODES[:SUCCESS])
66
+ end
67
+
63
68
  Aro::Mancy.game.show(**CLI::shoptions)
64
69
  end
65
70
  end
@@ -70,23 +75,23 @@ module CLI
70
75
  show_options_count = Aro::Mancy::S
71
76
  show_options_order = Aro::Log::ORDERING[:DESC]
72
77
 
73
- # Aro::P.say("ARGV.map{|a| a.to_sym} => #{ARGV.map{|a| a.to_sym}}")
78
+ # Aro::D.say("ARGV.map{|a| a.to_sym} => #{ARGV.map{|a| a.to_sym}}")
74
79
 
75
80
  count_option_flags = ARGV.map{|a| a.to_sym} & CLI::FLAGS[:SHOW_COUNT]
76
- # Aro::P.say("count_option_flags: #{count_option_flags}")
81
+ # Aro::D.say("count_option_flags: #{count_option_flags}")
77
82
  if count_option_flags.any?
78
83
  # get the ARGV index element after flag index
79
84
  show_options_count = ARGV[ARGV.index(count_option_flags.first.to_s) + 1]
80
85
  show_options_count = show_options_count.to_i unless [0, nil].include?(show_options_count&.to_i)
81
- # Aro::P.say("show_options_count: #{show_options_count}")
86
+ # Aro::D.say("show_options_count: #{show_options_count}")
82
87
  end
83
88
 
84
89
  order_option_flags = ARGV.map{|a| a.to_sym} & CLI::FLAGS[:SHOW_ORDER]
85
- # Aro::P.say("count_option_flags: #{order_option_flags}")
90
+ # Aro::D.say("count_option_flags: #{order_option_flags}")
86
91
  if order_option_flags.any?
87
92
  # get the ARGV index element after flag index
88
93
  show_options_order = ARGV[ARGV.index(order_option_flags.first.to_s) + 1].to_sym
89
- Aro::P.say("show_options_order: #{show_options_order}")
94
+ # Aro::D.say("show_options_order: #{show_options_order}")
90
95
  end
91
96
 
92
97
  {