aro 0.1.6 → 0.1.8

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -5
  3. data/.ruby-version +1 -1
  4. data/Gemfile.lock +32 -14
  5. data/aro.gemspec +17 -8
  6. data/bin/aos +19 -0
  7. data/bin/aro +24 -24
  8. data/checksums/aro-0.1.6.gem.sha512 +1 -0
  9. data/checksums/aro-0.1.7.gem.sha512 +1 -0
  10. data/checksums/aro-0.1.8.gem.sha512 +1 -0
  11. data/db/migrate/1763374647_create_decks.rb +3 -0
  12. data/db/migrate/1763432541_create_logs.rb +1 -0
  13. data/db/migrate/1765148774_create_yous.rb +19 -0
  14. data/listen.rb +10 -0
  15. data/locale/en.aos.yml +27 -0
  16. data/locale/en.cngelog.yml +5 -0
  17. data/locale/en.usage.yml +55 -38
  18. data/locale/en.yml +47 -15
  19. data/sys/aos/aos.rb +199 -0
  20. data/sys/aos/db.rb +81 -0
  21. data/sys/aos/s.rb +25 -0
  22. data/sys/aos/views/base.rb +139 -0
  23. data/sys/aos/views/dom.rb +45 -0
  24. data/sys/aos/views/games/abpps.rb +21 -0
  25. data/sys/aos/views/games/deck.rb +95 -0
  26. data/sys/aos/views/games/game.rb +24 -0
  27. data/sys/aos/views/games/hbpps.rb +21 -0
  28. data/sys/aos/views/games/shpps.rb +21 -0
  29. data/sys/aos/views/games/vipps.rb +21 -0
  30. data/sys/aos/views/games.rb +19 -0
  31. data/sys/aos/views/know/library.rb +19 -0
  32. data/sys/aos/views/know/temple.rb +19 -0
  33. data/sys/aos/views/know.rb +19 -0
  34. data/sys/aos/views/setup/settings.rb +50 -0
  35. data/sys/aos/views/setup.rb +19 -0
  36. data/sys/aos/views/welcome/waite.rb +19 -0
  37. data/sys/aos/views/welcome/winner.rb +19 -0
  38. data/sys/aos/views/welcome.rb +19 -0
  39. data/sys/aos/you.rb +15 -0
  40. data/sys/aro/d.rb +25 -0
  41. data/sys/aro/db.rb +89 -0
  42. data/sys/aro/mancy.rb +114 -0
  43. data/sys/aro/p.rb +25 -0
  44. data/sys/aro/r.rb +20 -0
  45. data/sys/aro/v.rb +24 -0
  46. data/sys/aro.rb +16 -0
  47. data/sys/cli/config.rb +582 -0
  48. data/sys/cli/constants.rb +56 -0
  49. data/{bin → sys}/cli/create.rb +6 -4
  50. data/sys/cli/deck.rb +98 -0
  51. data/sys/cli/dom.rb +37 -0
  52. data/sys/cli/nterface.rb +31 -0
  53. data/{bin → sys}/cli/usage.rb +1 -1
  54. data/sys/cli.rb +26 -0
  55. data/sys/dom/d.rb +101 -0
  56. data/sys/dom/dom.rb +161 -0
  57. data/sys/dom/p.rb +17 -0
  58. data/sys/models/deck.rb +218 -0
  59. data/sys/models/log.rb +20 -0
  60. data/sys/reiquire.rb +45 -0
  61. data/sys/shr/prompt.rb +37 -0
  62. data/sys/shr/t.rb +60 -0
  63. data/sys/shr/version.rb +16 -0
  64. data/tasks/make.rake +2 -2
  65. metadata +78 -22
  66. data/.release +0 -20
  67. data/bin/cli/config.rb +0 -231
  68. data/bin/cli/constants.rb +0 -39
  69. data/bin/cli/deck.rb +0 -100
  70. data/bin/cli.rb +0 -39
  71. data/lib/aro/c.rb +0 -32
  72. data/lib/aro/create.rb +0 -29
  73. data/lib/aro/db.rb +0 -107
  74. data/lib/aro/environment.rb +0 -3
  75. data/lib/aro/i18n.rb +0 -12
  76. data/lib/aro/prompt.rb +0 -25
  77. data/lib/aro/version.rb +0 -4
  78. data/lib/aro.rb +0 -45
  79. data/lib/models/deck.rb +0 -294
  80. data/lib/models/log.rb +0 -12
data/sys/cli/config.rb ADDED
@@ -0,0 +1,582 @@
1
+ =begin
2
+
3
+ config.rb
4
+
5
+ configuration interface.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module CLI
12
+
13
+ # cli entrypoint
14
+ def self.config
15
+ Aro::D.say("#{__FILE__}:#{__method__} was called (todo)...")
16
+ end
17
+
18
+ class Config
19
+ include Singleton
20
+
21
+ ARO_CONFIG_PREFIX = :ARO_CONFIG_
22
+ ARO_ENV_PREFIX = :ARO_ENV_
23
+
24
+ CONFIG_FILE = :".config"
25
+
26
+ DATE_FORMAT = "%Y:%m:%d:%H:%M:%S"
27
+
28
+ # possible envs
29
+ #
30
+ # example usage:
31
+ # CLI::Config::ENVS[:PRODUCTION]
32
+ ENVS = {
33
+ DEVELOPMENT: :development,
34
+ PRODUCTION: :production,
35
+ TEST: :test,
36
+ }
37
+
38
+ # possible formats
39
+ #
40
+ # example usage:
41
+ # CLI::Config::FORMATS[:TEXT]
42
+ FORMATS = {
43
+ TEXT: :text,
44
+ JSON: :json,
45
+ }
46
+
47
+ # possible dimensions
48
+ #
49
+ # example usage:
50
+ # CLI::Config::DMS[:DEV_TAROT]
51
+ DMS = {
52
+ DEV_TAROT: :dev_tarot,
53
+ RUBY_FACOT: :ruby_facot,
54
+ }
55
+
56
+ # ovar and ivar access
57
+ #
58
+ # example usage:
59
+ # CLI::Config::DEF_ACCESS[:READ]
60
+ DEF_ACCESS = {
61
+ READ: :read,
62
+ WRITE: :write
63
+ }
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
+
77
+ # types used in definition
78
+ #
79
+ # example usage:
80
+ # CLI::Config::DEF_TYPES[:INT][:validator].call(unvalid, CLI::Config::DEF[:DIMENSION])
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 v == CLI::Config::BOOLS[:TRUE].to_s
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
+ },
97
+ INT: {
98
+ name: :int,
99
+ description: I18n.t("cli.config.type.int_description"),
100
+ converter: Proc.new{|v| v.to_i},
101
+ validator: Proc.new{|unvalid, k, v|
102
+ int_valid = CLI::Config.def_valid?(k, v) &&
103
+ CLI::Config.int_valid?(unvalid) &&
104
+ unvalid.to_i >= v[:min] &&
105
+ unvalid.to_i <= v[:max]
106
+
107
+ Aro::V.say("validating #{k} (#{CLI::Config::DEF_TYPES[:INT][:name]})")
108
+ Aro::V.say("unvalid = #{unvalid}")
109
+ Aro::V.say("unvalid is#{int_valid ? " " : :" not ".to_s}valid.")
110
+ int_valid
111
+ }
112
+ },
113
+ STRING: {
114
+ name: :string,
115
+ description: I18n.t("cli.config.type.string_description"),
116
+ converter: Proc.new{|v| v.to_s},
117
+ validator: Proc.new{|unvalid, k, v|
118
+ CLI::Config.def_valid?(k, v) &&
119
+ CLI::Config.string_valid?(unvalid)
120
+ }
121
+ },
122
+ VALUES: {
123
+ name: :values,
124
+ description: I18n.t("cli.config.type.values_description"),
125
+ converter: Proc.new{|v| v.to_s},
126
+ validator: Proc.new{|unvalid, k, v|
127
+ CLI::Config.def_valid?(k, v) &&
128
+ v[:possible_values].keys.include?(unvalid&.to_sym)
129
+ }
130
+ },
131
+ }
132
+
133
+ def self.bool_valid?(unvalid)
134
+ CLI::Config::BOOLS.include?(unvalid&.to_s&.to_sym)
135
+ end
136
+
137
+ def self.int_valid?(unvalid)
138
+ !unvalid&.to_i.nil?
139
+ end
140
+
141
+ def self.string_valid?(unvalid)
142
+ unvalid.is_a?(String)
143
+ end
144
+
145
+ def self.def_valid?(key, deff)
146
+ def_valid = deff == CLI::Config::DEF[key]
147
+ unless def_valid
148
+ Aro::V.say("invalid def! #{key} => #{deff}")
149
+ end
150
+
151
+ def_valid
152
+ end
153
+
154
+ def validate_config
155
+ invalid_vars = []
156
+ CLI::Config::DEF.each{|k, v|
157
+ is_valid = valid_var?(ENV[CLI::Config.ivar_k(k)], k, v)
158
+ invalid_vars << k unless is_valid
159
+ }
160
+ invalid_vars
161
+ end
162
+
163
+ def valid_var?(var_value, k, v)
164
+ CLI::Config::DEF_TYPES[
165
+ v[:type].to_s.upcase.to_sym
166
+ ][:validator].call(var_value, k, v)
167
+ end
168
+
169
+ def convert_var_for_def(k)
170
+ CLI::Config::DEF_TYPES[
171
+ CLI::Config::DEF[k][:type].upcase
172
+ ][:converter].call(ENV[CLI::Config.ivar_k(k)])
173
+ end
174
+
175
+ # adapts I18n translations to generate bash environment vars.
176
+ #
177
+ # example usage:
178
+ # CLI::Config::DEF[:Z_MAX]
179
+ DEF = {
180
+
181
+ #
182
+ # => ivars
183
+ #
184
+ ENV: {
185
+ type: CLI::Config::TYPES[:VALUES],
186
+ access: CLI::Config::DEF_ACCESS[:WRITE],
187
+ value: CLI::Config::ENVS[:PRODUCTION],
188
+ description: I18n.t("cli.config.env.description"),
189
+ possible_values: {
190
+ development: I18n.t("cli.config.env.development_description"),
191
+ production: I18n.t("cli.config.env.production_description"),
192
+ test: I18n.t("cli.config.env.test_description"),
193
+ }
194
+ },
195
+ FORMAT: { # not implemented yet.
196
+ type: CLI::Config::TYPES[:VALUES],
197
+ implemented: false,
198
+ access: CLI::Config::DEF_ACCESS[:WRITE],
199
+ value: CLI::Config::FORMATS[:TEXT],
200
+ description: I18n.t("cli.config.format.description"),
201
+ possible_values: {
202
+ text: I18n.t("cli.config.format.text_description"),
203
+ json: I18n.t("cli.config.format.json_description")
204
+ }
205
+ },
206
+ DIMENSION: {
207
+ type: CLI::Config::TYPES[:VALUES],
208
+ access: CLI::Config::DEF_ACCESS[:WRITE],
209
+ value: CLI::Config::DMS[:DEV_TAROT],
210
+ description: I18n.t("cli.config.dimension.description"),
211
+ possible_values: {
212
+ dev_tarot: I18n.t("cli.config.dimension.dev_tarot_description"),
213
+ ruby_facot: I18n.t("cli.config.dimension.ruby_facot_description"),
214
+ }
215
+ },
216
+ HEIGHT: {
217
+ type: CLI::Config::TYPES[:INT],
218
+ access: CLI::Config::DEF_ACCESS[:WRITE],
219
+ value: Aro::Mancy::NUMERALS[:XLII],
220
+ min: Aro::Mancy::NUMERALS[:I],
221
+ max: Aro::Mancy::NUMERALS[:VII].pow(Aro::Mancy::OS),
222
+ description: I18n.t(
223
+ "cli.config.height_description",
224
+ min: Aro::Mancy::NUMERALS[:I],
225
+ max: Aro::Mancy::NUMERALS[:VII].pow(Aro::Mancy::OS),
226
+ ),
227
+ },
228
+ WIDTH: {
229
+ type: CLI::Config::TYPES[:INT],
230
+ access: CLI::Config::DEF_ACCESS[:WRITE],
231
+ value: Aro::Mancy::NUMERALS[:C] + Aro::Mancy::NUMERALS[:XXXVII] - Aro::Mancy::S,
232
+ min: Aro::Mancy::NUMERALS[:I],
233
+ max: Aro::Mancy::NUMERALS[:XI].pow(Aro::Mancy::OS),
234
+ description: I18n.t(
235
+ "cli.config.width_description",
236
+ min: Aro::Mancy::NUMERALS[:I],
237
+ max: Aro::Mancy::NUMERALS[:XI].pow(Aro::Mancy::OS),
238
+ ),
239
+ },
240
+ Z: {
241
+ type: CLI::Config::TYPES[:INT],
242
+ access: CLI::Config::DEF_ACCESS[:WRITE],
243
+ value: Aro::Mancy::NUMERALS[:I],
244
+ min: Aro::Mancy::NUMERALS[:I],
245
+ max: Aro::Mancy::NUMERALS[:MMXCVII],
246
+ description: I18n.t(
247
+ "cli.config.z_description",
248
+ min: Aro::Mancy::NUMERALS[:I],
249
+ max: Aro::Mancy::NUMERALS[:MMXCVII],
250
+ ),
251
+ },
252
+ Z_MAX: {
253
+ type: CLI::Config::TYPES[:INT],
254
+ access: CLI::Config::DEF_ACCESS[:WRITE],
255
+ value: Aro::Mancy::NUMERALS[:VII],
256
+ min: Aro::Mancy::NUMERALS[:I],
257
+ max: Aro::Mancy::NUMERALS[:XXII],
258
+ description: I18n.t(
259
+ "cli.config.z_max_description",
260
+ min: Aro::Mancy::NUMERALS[:I],
261
+ max: Aro::Mancy::NUMERALS[:XXII],
262
+ ),
263
+ },
264
+ VERBOSE: {
265
+ type: CLI::Config::TYPES[:BOOL],
266
+ access: CLI::Config::DEF_ACCESS[:WRITE],
267
+ value: CLI::Config::BOOLS[:FALSE],
268
+ description: I18n.t("cli.config.verbose_description"),
269
+ },
270
+
271
+ #
272
+ # => ovars
273
+ #
274
+ ARO_ENV_O: {
275
+ type: CLI::Config::TYPES[:INT],
276
+ access: CLI::Config::DEF_ACCESS[:READ],
277
+ value: Aro::Mancy::O,
278
+ description: I18n.t("cli.config.aro_env.O_description"),
279
+ },
280
+ ARO_ENV_S: {
281
+ type: CLI::Config::TYPES[:INT],
282
+ access: CLI::Config::DEF_ACCESS[:READ],
283
+ value: Aro::Mancy::S,
284
+ description: I18n.t("cli.config.aro_env.S_description"),
285
+ },
286
+ ARO_ENV_OS: {
287
+ type: CLI::Config::TYPES[:INT],
288
+ access: CLI::Config::DEF_ACCESS[:READ],
289
+ value: Aro::Mancy::OS,
290
+ description: I18n.t("cli.config.aro_env.OS_description"),
291
+ },
292
+ ARO_ENV_E: {
293
+ type: CLI::Config::TYPES[:INT],
294
+ access: CLI::Config::DEF_ACCESS[:READ],
295
+ value: Aro::Mancy::E,
296
+ description: I18n.t("cli.config.aro_env.E_description"),
297
+ },
298
+ ARO_ENV_N: {
299
+ type: CLI::Config::TYPES[:INT],
300
+ access: CLI::Config::DEF_ACCESS[:READ],
301
+ value: Aro::Mancy::N,
302
+ description: I18n.t("cli.config.aro_env.N_description"),
303
+ },
304
+ ARO_ENV_PS1: {
305
+ type: CLI::Config::TYPES[:STRING],
306
+ access: CLI::Config::DEF_ACCESS[:READ],
307
+ value: Aro::Mancy::PS1,
308
+ description: I18n.t("cli.config.aro_env.PS1_description"),
309
+ },
310
+ ARO_ENV_NAME_FILE: {
311
+ type: CLI::Config::TYPES[:STRING],
312
+ access: CLI::Config::DEF_ACCESS[:READ],
313
+ value: Aro::Mancy::NAME_FILE,
314
+ description: I18n.t("cli.config.aro_env.NAME_FILE_description"),
315
+ },
316
+ ARO_ENV_I2097I: {
317
+ type: CLI::Config::TYPES[:STRING],
318
+ access: CLI::Config::DEF_ACCESS[:READ],
319
+ value: Aro::Mancy::I2097I,
320
+ description: I18n.t("cli.config.aro_env.I2097I_description"),
321
+ },
322
+ ARO_ENV_YES: {
323
+ type: CLI::Config::TYPES[:STRING],
324
+ access: CLI::Config::DEF_ACCESS[:READ],
325
+ value: Aro::Mancy::YES,
326
+ description: I18n.t("cli.config.aro_env.YES_description"),
327
+ },
328
+ ARO_ENV_ALL: {
329
+ type: CLI::Config::TYPES[:STRING],
330
+ access: CLI::Config::DEF_ACCESS[:READ],
331
+ value: Aro::Mancy::ALL,
332
+ description: I18n.t("cli.config.aro_env.ALL_description"),
333
+ },
334
+ }
335
+
336
+ def initialize
337
+ @@context = nil
338
+ if Aro::Mancy.is_aro_space? && Aro::Mancy.is_initialized?
339
+ @@context = Aro::Mancy.name
340
+ elsif Aro::Dom.in_arodom?
341
+ @@context = Aro::Dom.name
342
+ end
343
+
344
+ return if @@context.nil?
345
+
346
+ unless File.exist?(CLI::Config.config_filepath)
347
+ generate_config
348
+ end
349
+
350
+ source_config
351
+ setup_env
352
+ end
353
+
354
+ def self.config_filepath
355
+ db_cls = @@context == Aro::Dom.name ? Aos::Db : Aro::Db
356
+ File.join(db_cls.base_aro_dir, CLI::Config::CONFIG_FILE.to_s)
357
+ end
358
+
359
+ def self.display_config
360
+ Aro::V.say(__method__)
361
+ width = CLI::Config.ivar(:WIDTH).to_i
362
+ columns = width.pow(Aro::Mancy::S.to_f / Aro::Mancy::OS.to_f).to_i
363
+ result = {
364
+ COLUMNS: columns,
365
+ HEIGHT: CLI::Config.ivar(:HEIGHT).to_i,
366
+ WIDTH: width,
367
+ DIVIDER: :"-".to_s
368
+ }
369
+ Aro::V.say(result)
370
+
371
+ result
372
+ end
373
+
374
+ # out vars
375
+ def self.ovar(suffix)
376
+ CLI::Config::DEF[suffix][:value]
377
+ end
378
+ # out vars
379
+ def self.ovar_k(suffix)
380
+ "#{CLI::Config::ARO_ENV_PREFIX}#{suffix}"
381
+ end
382
+
383
+ # in vars
384
+ def self.ivar(suffix)
385
+ ENV[CLI::Config.ivar_k(suffix)]
386
+ end
387
+ # in vars
388
+ def self.ivar_k(suffix)
389
+ "#{CLI::Config::ARO_CONFIG_PREFIX}#{suffix}"
390
+ end
391
+
392
+ def setup_env
393
+ # do not change - update $ARO_CONFIG_ENV .aro/.config file
394
+ #
395
+ # default is production
396
+ varenv = CLI::Config.ivar(:ENV)
397
+ is_valid = valid_var?(varenv, :ENV, CLI::Config::DEF[:ENV])
398
+ ENV[:ARO_ENV.to_s] = is_valid ? varenv : CLI::Config::ENVS[:PRODUCTION].to_s
399
+ Aro::D.say("setup_env: #{ENV[:ARO_ENV.to_s]}")
400
+ end
401
+
402
+ def self.is_test?
403
+ ENV[:ARO_ENV.to_s] == CLI::Config::ENVS[:TEST].to_s
404
+ end
405
+
406
+ def source_config
407
+ Aro::D.say(I18n.t("cli.config.source", name: CLI::Config.config_filepath))
408
+ File.read(CLI::Config.config_filepath).split("\n").select{|line|
409
+ line.match?(/export #{CLI::Config::ARO_CONFIG_PREFIX}/)
410
+ }.map{|line|
411
+ line.gsub("export ", "").split("=")
412
+ }.each{|kv|
413
+ Aro::V.say("variable to set: #{kv}")
414
+ ENV[kv[0]] = kv[1] # source
415
+ Aro::V.say("value actually set: #{ENV[kv[0]]}")
416
+ }
417
+
418
+ # todo: implement
419
+ invalid_defs = validate_config
420
+ CLI::Config::DEF.keys.each{|dfk|
421
+ Aro::V.say("$#{CLI::Config.ivar_k(dfk)}=#{CLI::Config.ivar(dfk)}")
422
+ }
423
+ Aro::V.say("todo: invalid_defs: #{invalid_defs}")
424
+ # todo: set all invalid_refs to default in ENV
425
+ # invalid_defs.each{|id|
426
+
427
+ # }
428
+ end
429
+
430
+ def generate_config
431
+ # todo: localize generated config text
432
+ Aro::D.say(I18n.t("cli.config.generate", name: CLI::Config.config_filepath))
433
+ File.open(CLI::Config.config_filepath, "w+") do |file|
434
+ # intro
435
+ Aro::Mancy::OS.times do
436
+ print_div file.object_id
437
+ end
438
+ # header
439
+ print_div file.object_id
440
+ print_sr file.object_id
441
+ print_config_header file.object_id
442
+ print_sr file.object_id
443
+ print_div file.object_id
444
+
445
+ print_osr file.object_id
446
+
447
+ # def_types
448
+ print_div file.object_id
449
+ print_sr file.object_id
450
+ print_def_types file.object_id
451
+ print_sr file.object_id
452
+ print_div file.object_id
453
+
454
+ print_osr file.object_id
455
+
456
+ # var section
457
+ print_div file.object_id
458
+ print_sr file.object_id
459
+ print_var_section file.object_id
460
+ print_sr file.object_id
461
+ print_div file.object_id
462
+
463
+ print_osr file.object_id
464
+
465
+ # vars
466
+ CLI::Config::DEF.each{|k, v|
467
+ print_var file.object_id, k, v
468
+ }
469
+
470
+ print_osr file.object_id
471
+
472
+ # var section
473
+ print_div file.object_id
474
+ print_sr file.object_id
475
+ print_var_section file.object_id
476
+ print_sr file.object_id
477
+ print_div file.object_id
478
+
479
+ print_osr file.object_id
480
+ # outro
481
+ Aro::Mancy::OS.times do
482
+ print_div file.object_id
483
+ end
484
+ file.write("\n")
485
+ end
486
+ end
487
+
488
+ def print_div f_object_id
489
+ file = ObjectSpace._id2ref f_object_id
490
+ file.write("#{"#" * Aro::Mancy::NUMERALS[:VIII].pow(2)}\n")
491
+ end
492
+
493
+ def print_sr f_object_id
494
+ file = ObjectSpace._id2ref f_object_id
495
+ Aro::Mancy::S.times do
496
+ file.write("#\n")
497
+ end
498
+ end
499
+
500
+ def print_osr f_object_id
501
+ Aro::Mancy::OS.times do
502
+ print_sr f_object_id
503
+ end
504
+ end
505
+
506
+ def print_config_header f_object_id
507
+ file = ObjectSpace._id2ref f_object_id
508
+ file.write("# #{Aro::Mancy::PS1} configuration file.\n")
509
+ file.write("# this file was auto generated by the aro cli.\n")
510
+ end
511
+
512
+ def print_var_section f_object_id
513
+ file = ObjectSpace._id2ref f_object_id
514
+ file.write("# VARIABLE SECTION!\n")
515
+ end
516
+
517
+ def print_def_types f_object_id
518
+ file = ObjectSpace._id2ref f_object_id
519
+ file.write("# CLI::Config::DEF_TYPES\n")
520
+ file.write("# describes the possible types of variables.\n")
521
+ CLI::Config::DEF_TYPES.each{|k, v|
522
+ file.write("# #{k}: #{v[:description]}\n")
523
+ }
524
+ print_osr f_object_id
525
+ file.write("# CLI::Config::DEF\n")
526
+ file.write("# define & expose an aro bash api via ENV variables.\n")
527
+ file.write("# there are two types of bash vars in aro.\n")
528
+ file.write("# 1) in vars (ivars). \n")
529
+ file.write("# => ivars enter aro from this file during aro init.\n")
530
+ file.write("# => aro validates them and uses them unless unvalid.\n")
531
+ file.write("# => otherwise aro will use the defaults listed below.\n")
532
+ file.write("# 2) out vars (ovars).\n")
533
+ file.write("# => ovars are read-only vars that aro exposes to bash.\n")
534
+ file.write("# => this is useful because it provides a bash interface\n")
535
+ file.write("# => which can be used to write programs on top of aro.\n")
536
+ end
537
+
538
+ def print_var f_object_id, k, v
539
+ file = ObjectSpace._id2ref f_object_id
540
+
541
+ is_ovar = CLI::Config::DEF[k][:access] == CLI::Config::DEF_ACCESS[:READ]
542
+ if is_ovar
543
+ var_name = k
544
+ else
545
+ var_name = CLI::Config.ivar_k(k)
546
+ end
547
+ Aro::V.say("access for #{k} is #{CLI::Config::DEF[k][:access]}")
548
+ Aro::V.say("using var_name: #{var_name}")
549
+ file.write("# [#{var_name}] (#{is_ovar ? :ovar : :ivar})\n")
550
+ file.write("# => #{I18n.t("cli.config.def_type")}: #{v[:type]}\n")
551
+ case v[:type]
552
+ when CLI::Config::DEF_TYPES[:INT][:name]
553
+ file.write("# => #{I18n.t("cli.config.type.int_description")}\n")
554
+ file.write("# => #{I18n.t("cli.config.minimum")}: #{v[:min]}\n")
555
+ file.write("# => #{I18n.t("cli.config.maximum")}: #{v[:max]}\n")
556
+ when CLI::Config::DEF_TYPES[:STRING][:name]
557
+ file.write("# => #{I18n.t("cli.config.type.string_description")}\n")
558
+ file.write("# => use \"double quotes\" if there are any spaces.\n")
559
+ when CLI::Config::DEF_TYPES[:VALUES][:name]
560
+ file.write("# => #{I18n.t("cli.config.type.values_description")}\n")
561
+ file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
562
+ print_sr f_object_id
563
+ v[:possible_values].each{|name, description|
564
+ file.write("# => #{name}\n")
565
+ print_sr f_object_id
566
+ file.write("# =>#{description}\n")
567
+ print_sr f_object_id
568
+ }
569
+ end
570
+ print_osr f_object_id
571
+ file.write("# => description:\n")
572
+ file.write("# => #{v[:description]}\n")
573
+ if is_ovar && CLI::Config::DEF_TYPES[:STRING][:name] == v[:type]
574
+ file.write("export #{var_name}=\"#{v[:value]}\"\n")
575
+ else
576
+ file.write("export #{var_name}=#{v[:value]}\n")
577
+ end
578
+ print_osr f_object_id
579
+ end
580
+
581
+ end
582
+ end
@@ -0,0 +1,56 @@
1
+ =begin
2
+
3
+ constants.rb
4
+
5
+ define constants for the aro cli.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module CLI
12
+
13
+ FLAGS = {
14
+ HELP: [:"-h", :"--help"],
15
+ SHOW_COUNT: [:"-n", :"--count"],
16
+ SHOW_ORDER: [:"-o", :"--order"],
17
+ VERSION: [:"-v", :"--version"],
18
+ }
19
+
20
+ EXIT_CODES = {
21
+ SUCCESS: 0,
22
+ GENERAL_ERROR: 1,
23
+ INVALID_ARG: 3
24
+ }
25
+
26
+ CMDS = {
27
+ AOS: {
28
+ RUN: :run,
29
+ WATCH: :watch,
30
+ },
31
+ ARO: {
32
+ CREATE: :create,
33
+ CONFIG: :config,
34
+ DECK: :deck,
35
+ DOM: :dom,
36
+ INIT: :init,
37
+ },
38
+ CONFIG: {
39
+ # ...
40
+ },
41
+ DECK: {
42
+ DRAW: :draw,
43
+ EXPLORE: :explore,
44
+ NEW: :new,
45
+ REPLACE: :replace,
46
+ RESET: :reset,
47
+ SHOW: :show,
48
+ SHUFFLE: :shuffle,
49
+ },
50
+ DOM: {
51
+ INIT: :init,
52
+ NEW: :new,
53
+ },
54
+ }
55
+
56
+ end
@@ -1,19 +1,21 @@
1
1
  =begin
2
2
 
3
- constants.rb
3
+ aro.rb
4
4
 
5
- process aro creation commands
5
+ process aro commands.
6
6
 
7
7
  by i2097i
8
8
 
9
9
  =end
10
10
 
11
11
  module CLI
12
+ # cli entrypoint
12
13
  def self.create
13
- CLI::Aroface.exit_error_missing_args! if CLI::ARGV1.nil?
14
+ CLI::Nterface.exit_error_missing_args! if CLI::ARGV1.nil?
15
+
14
16
  name = CLI::ARGV1&.to_s
15
17
  Aro::P.say(I18n.t("cli.messages.creation_attempt", name: name))
16
- if Aro::Create.new(name).initialized
18
+ if Aro::Mancy.create(name)
17
19
  Aro::P.say(I18n.t("cli.messages.creation_success", name: name))
18
20
  else
19
21
  Aro::P.say(I18n.t("cli.messages.creation_failure", name: name))