aro 0.2.0 → 0.2.1
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +3 -2
- data/aro.gemspec +1 -0
- data/bin/aos +2 -2
- data/bin/aro +1 -1
- data/listen.rb +1 -1
- data/locale/en.aos.yml +44 -5
- data/locale/en.dom.yml +2 -2
- data/locale/en.usage.yml +2 -2
- data/locale/en.yml +1 -0
- data/sys/aos/amg.rb +182 -0
- data/sys/aos/aos.rb +144 -63
- data/sys/aos/db/migrate/1765762724_create_libs.rb +22 -0
- data/sys/aos/db.rb +8 -9
- data/sys/aos/{views → vws}/base.rb +64 -61
- data/sys/aos/{views → vws}/dom.rb +6 -9
- data/sys/aos/vws/games/abpps.rb +19 -0
- data/sys/aos/{views → vws}/games/game.rb +16 -15
- data/sys/aos/vws/games/hbpps.rb +19 -0
- data/sys/aos/vws/games/shpps.rb +19 -0
- data/sys/aos/vws/games/vipps.rb +19 -0
- data/sys/aos/{views → vws}/games.rb +3 -3
- data/sys/aos/{views → vws}/know/library.rb +3 -3
- data/sys/aos/{views → vws}/know/temple.rb +3 -3
- data/sys/aos/{views → vws}/know.rb +3 -3
- data/sys/aos/vws/setup/amg.rb +22 -0
- data/sys/aos/vws/setup/config.rb +21 -0
- data/sys/aos/{views → vws}/setup.rb +3 -3
- data/sys/aos/vws/welcome/waite.rb +30 -0
- data/sys/aos/{views → vws}/welcome/winner.rb +3 -3
- data/sys/aos/{views → vws}/welcome.rb +3 -3
- data/sys/aos/you.rb +6 -4
- data/sys/aro/db.rb +6 -5
- data/sys/aro/mancy.rb +1 -0
- data/sys/aro/v.rb +1 -1
- data/sys/cli/deck.rb +9 -4
- data/sys/cli.rb +8 -9
- data/sys/{cli → dom}/config.rb +153 -157
- data/sys/dom/d.rb +10 -5
- data/sys/dom/dom.rb +3 -2
- data/sys/models/deck.rb +13 -18
- data/sys/reiquire.rb +4 -3
- data/sys/shr/lib/crs/CMakeLists.txt +12 -0
- data/sys/shr/lib/crs/compile.sh +5 -0
- data/sys/shr/lib/crs/crs.c +24 -0
- data/sys/shr/lib/crs/crs.o +0 -0
- data/sys/shr/lib/crs/libcrs.so +0 -0
- data/sys/shr/lib/lib.rb +43 -0
- data/sys/shr/prompt.rb +2 -2
- data/sys/shr/t.rb +14 -8
- data/sys/shr/version.rb +1 -1
- metadata +50 -21
- data/sys/aos/views/games/abpps.rb +0 -21
- data/sys/aos/views/games/hbpps.rb +0 -21
- data/sys/aos/views/games/shpps.rb +0 -21
- data/sys/aos/views/games/vipps.rb +0 -21
- data/sys/aos/views/setup/settings.rb +0 -37
- data/sys/aos/views/welcome/waite.rb +0 -19
- /data/{db → sys/aos/db}/migrate/1765148774_create_yous.rb +0 -0
- /data/{db → sys/aro/db}/migrate/1763374647_create_decks.rb +0 -0
- /data/{db → sys/aro/db}/migrate/1763432541_create_logs.rb +0 -0
data/sys/{cli → dom}/config.rb
RENAMED
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
config.rb
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
dom config interface.
|
|
6
6
|
|
|
7
7
|
by i2097i
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
|
-
module
|
|
11
|
+
module Aro
|
|
12
12
|
|
|
13
13
|
# cli entrypoint
|
|
14
14
|
def self.config
|
|
15
|
-
|
|
15
|
+
Aro::Config.process_config_command(ARGV)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
class Config
|
|
19
19
|
include Singleton
|
|
20
20
|
|
|
21
|
+
attr_accessor :config_path, :display_lines
|
|
22
|
+
|
|
21
23
|
ARO_CONFIG_PREFIX = :ARO_CONFIG_
|
|
22
24
|
ARO_ENV_PREFIX = :ARO_ENV_
|
|
23
25
|
|
|
@@ -28,7 +30,7 @@ module CLI
|
|
|
28
30
|
# possible envs
|
|
29
31
|
#
|
|
30
32
|
# example usage:
|
|
31
|
-
#
|
|
33
|
+
# Aro::Config::ENVS[:PRODUCTION]
|
|
32
34
|
ENVS = {
|
|
33
35
|
DEVELOPMENT: :development,
|
|
34
36
|
PRODUCTION: :production,
|
|
@@ -38,7 +40,7 @@ module CLI
|
|
|
38
40
|
# possible formats
|
|
39
41
|
#
|
|
40
42
|
# example usage:
|
|
41
|
-
#
|
|
43
|
+
# Aro::Config::FORMATS[:TEXT]
|
|
42
44
|
FORMATS = {
|
|
43
45
|
TEXT: :text,
|
|
44
46
|
JSON: :json,
|
|
@@ -47,7 +49,7 @@ module CLI
|
|
|
47
49
|
# possible dimensions
|
|
48
50
|
#
|
|
49
51
|
# example usage:
|
|
50
|
-
#
|
|
52
|
+
# Aro::Config::DMS[:DEV_TAROT]
|
|
51
53
|
DMS = {
|
|
52
54
|
DEV_TAROT: :dev_tarot,
|
|
53
55
|
RUBY_FACOT: :ruby_facot,
|
|
@@ -56,7 +58,7 @@ module CLI
|
|
|
56
58
|
# ovar and ivar access
|
|
57
59
|
#
|
|
58
60
|
# example usage:
|
|
59
|
-
#
|
|
61
|
+
# Aro::Config::DEF_ACCESS[:READ]
|
|
60
62
|
DEF_ACCESS = {
|
|
61
63
|
READ: :read,
|
|
62
64
|
WRITE: :write
|
|
@@ -77,21 +79,21 @@ module CLI
|
|
|
77
79
|
# types used in definition
|
|
78
80
|
#
|
|
79
81
|
# example usage:
|
|
80
|
-
#
|
|
82
|
+
# Aro::Config::DEF_TYPES[:INT][:validator].call(unvalid, Aro::Config::DEF[:DIMENSION])
|
|
81
83
|
DEF_TYPES = {
|
|
82
84
|
BOOL: {
|
|
83
|
-
name:
|
|
85
|
+
name: Aro::Config::TYPES[:BOOL],
|
|
84
86
|
description: I18n.t("cli.config.type.bool_description"),
|
|
85
87
|
converter: Proc.new{|v|
|
|
86
|
-
if [
|
|
87
|
-
|
|
88
|
+
if [Aro::Config::BOOLS[:TRUE].to_s, Aro::Mancy::S].include?(v)
|
|
89
|
+
Aro::Config::BOOLS[:TRUE]
|
|
88
90
|
else
|
|
89
|
-
|
|
91
|
+
Aro::Config::BOOLS[:FALSE]
|
|
90
92
|
end
|
|
91
93
|
},
|
|
92
94
|
validator: Proc.new{|unvalid, k, v|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
Aro::Config.def_valid?(k, v) &&
|
|
96
|
+
Aro::Config.bool_valid?(unvalid)
|
|
95
97
|
}
|
|
96
98
|
},
|
|
97
99
|
INT: {
|
|
@@ -99,11 +101,11 @@ module CLI
|
|
|
99
101
|
description: I18n.t("cli.config.type.int_description"),
|
|
100
102
|
converter: Proc.new{|v| v.to_i},
|
|
101
103
|
validator: Proc.new{|unvalid, k, v|
|
|
102
|
-
Aro::V.say("validating #{k} (#{
|
|
104
|
+
Aro::V.say("validating #{k} (#{Aro::Config::DEF_TYPES[:INT][:name]})")
|
|
103
105
|
Aro::V.say("unvalid = #{unvalid}")
|
|
104
106
|
Aro::V.say("[min, max] = [#{v[:min]}, #{v[:max]}]")
|
|
105
|
-
int_valid =
|
|
106
|
-
|
|
107
|
+
int_valid = Aro::Config.def_valid?(k, v) &&
|
|
108
|
+
Aro::Config.int_valid?(unvalid) &&
|
|
107
109
|
unvalid.to_i >= v[:min] &&
|
|
108
110
|
unvalid.to_i <= v[:max]
|
|
109
111
|
Aro::V.say("unvalid(#{unvalid}) is#{int_valid ? " " : :" not ".to_s}valid.")
|
|
@@ -115,8 +117,8 @@ module CLI
|
|
|
115
117
|
description: I18n.t("cli.config.type.string_description"),
|
|
116
118
|
converter: Proc.new{|v| v.to_s},
|
|
117
119
|
validator: Proc.new{|unvalid, k, v|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
Aro::Config.def_valid?(k, v) &&
|
|
121
|
+
Aro::Config.string_valid?(unvalid)
|
|
120
122
|
}
|
|
121
123
|
},
|
|
122
124
|
VALUES: {
|
|
@@ -124,14 +126,14 @@ module CLI
|
|
|
124
126
|
description: I18n.t("cli.config.type.values_description"),
|
|
125
127
|
converter: Proc.new{|v| v.to_s},
|
|
126
128
|
validator: Proc.new{|unvalid, k, v|
|
|
127
|
-
|
|
129
|
+
Aro::Config.def_valid?(k, v) &&
|
|
128
130
|
v[:possible_values].keys.include?(unvalid&.to_sym)
|
|
129
131
|
}
|
|
130
132
|
},
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
def self.bool_valid?(unvalid)
|
|
134
|
-
|
|
136
|
+
Aro::Config::BOOLS.values.map{|b| b.to_s.to_sym}.include?(unvalid&.to_s&.to_sym)
|
|
135
137
|
end
|
|
136
138
|
|
|
137
139
|
def self.int_valid?(unvalid)
|
|
@@ -143,7 +145,7 @@ module CLI
|
|
|
143
145
|
end
|
|
144
146
|
|
|
145
147
|
def self.def_valid?(key, deff)
|
|
146
|
-
def_valid = deff ==
|
|
148
|
+
def_valid = deff == Aro::Config::DEF[key]
|
|
147
149
|
unless def_valid
|
|
148
150
|
Aro::V.say("invalid def! #{key} => #{deff}")
|
|
149
151
|
end
|
|
@@ -153,10 +155,10 @@ module CLI
|
|
|
153
155
|
|
|
154
156
|
def validate_config
|
|
155
157
|
invalid_vars = []
|
|
156
|
-
|
|
157
|
-
is_valid = v[:access] ==
|
|
158
|
+
Aro::Config::DEF.each{|k, v|
|
|
159
|
+
is_valid = v[:access] == Aro::Config::DEF_ACCESS[:READ]
|
|
158
160
|
unless is_valid
|
|
159
|
-
is_valid = valid_var?(
|
|
161
|
+
is_valid = valid_var?(Aro::Config.ivar(k), k, v)
|
|
160
162
|
end
|
|
161
163
|
invalid_vars << k unless is_valid
|
|
162
164
|
}
|
|
@@ -165,32 +167,32 @@ module CLI
|
|
|
165
167
|
|
|
166
168
|
def valid_var?(var_value, k, v)
|
|
167
169
|
Aro::V.say(v)
|
|
168
|
-
return true if v[:access] ==
|
|
170
|
+
return true if v[:access] == Aro::Config::DEF_ACCESS[:READ]
|
|
169
171
|
|
|
170
|
-
|
|
172
|
+
Aro::Config::DEF_TYPES[
|
|
171
173
|
v[:type].to_s.upcase.to_sym
|
|
172
174
|
][:validator].call(var_value, k, v)
|
|
173
175
|
end
|
|
174
176
|
|
|
175
177
|
def convert_var_for_def(k)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
][:converter].call(ENV[
|
|
178
|
+
Aro::Config::DEF_TYPES[
|
|
179
|
+
Aro::Config::DEF[k][:type].upcase
|
|
180
|
+
][:converter].call(ENV[Aro::Config.ivar_k(k)])
|
|
179
181
|
end
|
|
180
182
|
|
|
181
183
|
# adapts I18n translations to generate bash environment vars.
|
|
182
184
|
#
|
|
183
185
|
# example usage:
|
|
184
|
-
#
|
|
186
|
+
# Aro::Config::DEF[:Z_MAX]
|
|
185
187
|
DEF = {
|
|
186
188
|
|
|
187
189
|
#
|
|
188
190
|
# => ivars
|
|
189
191
|
#
|
|
190
192
|
ENV: {
|
|
191
|
-
type:
|
|
192
|
-
access:
|
|
193
|
-
value:
|
|
193
|
+
type: Aro::Config::TYPES[:VALUES],
|
|
194
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
195
|
+
value: Aro::Config::ENVS[:PRODUCTION],
|
|
194
196
|
description: I18n.t("cli.config.env.description"),
|
|
195
197
|
possible_values: {
|
|
196
198
|
development: I18n.t("cli.config.env.development_description"),
|
|
@@ -199,28 +201,28 @@ module CLI
|
|
|
199
201
|
}
|
|
200
202
|
},
|
|
201
203
|
VERBOSE: {
|
|
202
|
-
type:
|
|
203
|
-
access:
|
|
204
|
-
value:
|
|
204
|
+
type: Aro::Config::TYPES[:BOOL],
|
|
205
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
206
|
+
value: Aro::Config::BOOLS[:FALSE],
|
|
205
207
|
description: I18n.t("cli.config.verbose_description"),
|
|
206
208
|
},
|
|
207
209
|
LOG_AOS_DB: {
|
|
208
|
-
type:
|
|
209
|
-
access:
|
|
210
|
-
value:
|
|
210
|
+
type: Aro::Config::TYPES[:BOOL],
|
|
211
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
212
|
+
value: Aro::Config::BOOLS[:FALSE],
|
|
211
213
|
description: I18n.t("cli.config.log_aos_db_description"),
|
|
212
214
|
},
|
|
213
215
|
LOG_ARO_DB: {
|
|
214
|
-
type:
|
|
215
|
-
access:
|
|
216
|
-
value:
|
|
216
|
+
type: Aro::Config::TYPES[:BOOL],
|
|
217
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
218
|
+
value: Aro::Config::BOOLS[:FALSE],
|
|
217
219
|
description: I18n.t("cli.config.log_aro_db_description"),
|
|
218
220
|
},
|
|
219
221
|
FORMAT: { # not implemented yet.
|
|
220
|
-
type:
|
|
222
|
+
type: Aro::Config::TYPES[:VALUES],
|
|
221
223
|
implemented: false,
|
|
222
|
-
access:
|
|
223
|
-
value:
|
|
224
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
225
|
+
value: Aro::Config::FORMATS[:TEXT],
|
|
224
226
|
description: I18n.t("cli.config.format.description"),
|
|
225
227
|
possible_values: {
|
|
226
228
|
text: I18n.t("cli.config.format.text_description"),
|
|
@@ -228,9 +230,9 @@ module CLI
|
|
|
228
230
|
}
|
|
229
231
|
},
|
|
230
232
|
DIMENSION: {
|
|
231
|
-
type:
|
|
232
|
-
access:
|
|
233
|
-
value:
|
|
233
|
+
type: Aro::Config::TYPES[:VALUES],
|
|
234
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
235
|
+
value: Aro::Config::DMS[:DEV_TAROT],
|
|
234
236
|
description: I18n.t("cli.config.dimension.description"),
|
|
235
237
|
possible_values: {
|
|
236
238
|
dev_tarot: I18n.t("cli.config.dimension.dev_tarot_description"),
|
|
@@ -238,8 +240,8 @@ module CLI
|
|
|
238
240
|
}
|
|
239
241
|
},
|
|
240
242
|
HEIGHT: {
|
|
241
|
-
type:
|
|
242
|
-
access:
|
|
243
|
+
type: Aro::Config::TYPES[:INT],
|
|
244
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
243
245
|
value: Aro::Mancy::NUMERALS[:XLII],
|
|
244
246
|
min: Aro::Mancy::NUMERALS[:I],
|
|
245
247
|
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
@@ -250,8 +252,8 @@ module CLI
|
|
|
250
252
|
),
|
|
251
253
|
},
|
|
252
254
|
WIDTH: {
|
|
253
|
-
type:
|
|
254
|
-
access:
|
|
255
|
+
type: Aro::Config::TYPES[:INT],
|
|
256
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
255
257
|
value: Aro::Mancy::NUMERALS[:C] + Aro::Mancy::NUMERALS[:XXXVII] - Aro::Mancy::S,
|
|
256
258
|
min: Aro::Mancy::NUMERALS[:I],
|
|
257
259
|
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
@@ -262,8 +264,8 @@ module CLI
|
|
|
262
264
|
),
|
|
263
265
|
},
|
|
264
266
|
Z: {
|
|
265
|
-
type:
|
|
266
|
-
access:
|
|
267
|
+
type: Aro::Config::TYPES[:INT],
|
|
268
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
267
269
|
value: Aro::Mancy::NUMERALS[:I],
|
|
268
270
|
min: Aro::Mancy::NUMERALS[:I],
|
|
269
271
|
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
@@ -274,8 +276,8 @@ module CLI
|
|
|
274
276
|
),
|
|
275
277
|
},
|
|
276
278
|
Z_MAX: {
|
|
277
|
-
type:
|
|
278
|
-
access:
|
|
279
|
+
type: Aro::Config::TYPES[:INT],
|
|
280
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
279
281
|
value: Aro::Mancy::NUMERALS[:VII],
|
|
280
282
|
min: Aro::Mancy::NUMERALS[:I],
|
|
281
283
|
max: Aro::Mancy::NUMERALS[:XXII],
|
|
@@ -290,116 +292,115 @@ module CLI
|
|
|
290
292
|
# => ovars
|
|
291
293
|
#
|
|
292
294
|
ARO_ENV_O: {
|
|
293
|
-
type:
|
|
294
|
-
access:
|
|
295
|
+
type: Aro::Config::TYPES[:INT],
|
|
296
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
295
297
|
value: Aro::Mancy::O,
|
|
296
298
|
description: I18n.t("cli.config.aro_env.O_description"),
|
|
297
299
|
},
|
|
298
300
|
ARO_ENV_S: {
|
|
299
|
-
type:
|
|
300
|
-
access:
|
|
301
|
+
type: Aro::Config::TYPES[:INT],
|
|
302
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
301
303
|
value: Aro::Mancy::S,
|
|
302
304
|
description: I18n.t("cli.config.aro_env.S_description"),
|
|
303
305
|
},
|
|
304
306
|
ARO_ENV_OS: {
|
|
305
|
-
type:
|
|
306
|
-
access:
|
|
307
|
+
type: Aro::Config::TYPES[:INT],
|
|
308
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
307
309
|
value: Aro::Mancy::OS,
|
|
308
310
|
description: I18n.t("cli.config.aro_env.OS_description"),
|
|
309
311
|
},
|
|
310
312
|
ARO_ENV_E: {
|
|
311
|
-
type:
|
|
312
|
-
access:
|
|
313
|
+
type: Aro::Config::TYPES[:INT],
|
|
314
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
313
315
|
value: Aro::Mancy::E,
|
|
314
316
|
description: I18n.t("cli.config.aro_env.E_description"),
|
|
315
317
|
},
|
|
316
318
|
ARO_ENV_N: {
|
|
317
|
-
type:
|
|
318
|
-
access:
|
|
319
|
+
type: Aro::Config::TYPES[:INT],
|
|
320
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
319
321
|
value: Aro::Mancy::N,
|
|
320
322
|
description: I18n.t("cli.config.aro_env.N_description"),
|
|
321
323
|
},
|
|
322
324
|
ARO_ENV_PS1: {
|
|
323
|
-
type:
|
|
324
|
-
access:
|
|
325
|
+
type: Aro::Config::TYPES[:STRING],
|
|
326
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
325
327
|
value: Aro::Mancy::PS1,
|
|
326
328
|
description: I18n.t("cli.config.aro_env.PS1_description"),
|
|
327
329
|
},
|
|
328
330
|
ARO_ENV_NAME_FILE: {
|
|
329
|
-
type:
|
|
330
|
-
access:
|
|
331
|
+
type: Aro::Config::TYPES[:STRING],
|
|
332
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
331
333
|
value: Aro::Mancy::NAME_FILE,
|
|
332
334
|
description: I18n.t("cli.config.aro_env.NAME_FILE_description"),
|
|
333
335
|
},
|
|
334
336
|
ARO_ENV_I2097I: {
|
|
335
|
-
type:
|
|
336
|
-
access:
|
|
337
|
+
type: Aro::Config::TYPES[:STRING],
|
|
338
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
337
339
|
value: Aro::Mancy::I2097I,
|
|
338
340
|
description: I18n.t("cli.config.aro_env.I2097I_description"),
|
|
339
341
|
},
|
|
340
342
|
ARO_ENV_YES: {
|
|
341
|
-
type:
|
|
342
|
-
access:
|
|
343
|
+
type: Aro::Config::TYPES[:STRING],
|
|
344
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
343
345
|
value: Aro::Mancy::YES,
|
|
344
346
|
description: I18n.t("cli.config.aro_env.YES_description"),
|
|
345
347
|
},
|
|
346
348
|
ARO_ENV_ALL: {
|
|
347
|
-
type:
|
|
348
|
-
access:
|
|
349
|
+
type: Aro::Config::TYPES[:STRING],
|
|
350
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
349
351
|
value: Aro::Mancy::ALL,
|
|
350
352
|
description: I18n.t("cli.config.aro_env.ALL_description"),
|
|
351
353
|
},
|
|
352
354
|
}
|
|
353
355
|
|
|
354
|
-
def
|
|
355
|
-
|
|
356
|
-
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
357
|
-
@@context = Aro::Db
|
|
358
|
-
elsif Aro::Dom.in_arodom? && Aro::Dom.is_initialized?
|
|
359
|
-
@@context = Aos::Db
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
return if @@context.nil?
|
|
363
|
-
Aro::V.say(@@context)
|
|
364
|
-
|
|
365
|
-
unless File.exist?(CLI::Config.config_filepath)
|
|
356
|
+
def load
|
|
357
|
+
unless File.exist?(Aro::Config.config_filepath)
|
|
366
358
|
generate_config
|
|
367
359
|
end
|
|
368
360
|
|
|
369
361
|
source_config
|
|
370
362
|
setup_env
|
|
363
|
+
|
|
364
|
+
self.display_lines = Aro::Config.base_lines
|
|
371
365
|
end
|
|
372
366
|
|
|
373
|
-
def self.
|
|
374
|
-
|
|
367
|
+
def self.base_lines
|
|
368
|
+
# print Aro::Config::DEF
|
|
369
|
+
lines = []
|
|
370
|
+
lines << "loaded config at: #{Aos::Os.osify(Aro::Config.config_filepath)}"
|
|
371
|
+
lines << "<Aro::Config::DEF>"
|
|
372
|
+
lines += Aro::Config.dump_config
|
|
373
|
+
|
|
374
|
+
# print config commands
|
|
375
|
+
lines << ""
|
|
376
|
+
lines << I18n.t("aos.constants.commands")
|
|
377
|
+
lines += Aos::Vw::Base.lines_for_cmd(Aos::Os::CMDS[:CONFIG])
|
|
378
|
+
lines
|
|
375
379
|
end
|
|
376
380
|
|
|
377
381
|
def self.config_filepath
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
Aro::Dom.
|
|
382
|
-
|
|
383
|
-
# override when in arodome game room
|
|
384
|
-
# this ensures the arodome config is being used
|
|
385
|
-
cfp = File.join(Aos::Db.base_aro_dir, CLI::Config::CONFIG_FILE.to_s)
|
|
386
|
-
else
|
|
387
|
-
cfp = File.join(@@context.base_aro_dir, CLI::Config::CONFIG_FILE.to_s)
|
|
382
|
+
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
383
|
+
self.instance.config_path = File.join(Dir.pwd, Aro::Db.base_aro_dir)
|
|
384
|
+
elsif Aro::Dom.in_arodom? && Aro::Dom.is_initialized?
|
|
385
|
+
self.instance.config_path = File.join(Aro::Dom::dom_root, Aro::Dom.room_path(:config))
|
|
388
386
|
end
|
|
389
387
|
|
|
390
|
-
|
|
388
|
+
File.join(
|
|
389
|
+
self.instance.config_path,
|
|
390
|
+
Aro::Config::CONFIG_FILE.to_s
|
|
391
|
+
)
|
|
391
392
|
end
|
|
392
393
|
|
|
393
394
|
def self.is_test?
|
|
394
|
-
ENV[:ARO_ENV.to_s] ==
|
|
395
|
+
ENV[:ARO_ENV.to_s] == Aro::Config::ENVS[:TEST].to_s
|
|
395
396
|
end
|
|
396
397
|
|
|
397
|
-
def self.
|
|
398
|
+
def self.display_configuration
|
|
398
399
|
height, width = IO.console.winsize
|
|
399
400
|
result = {
|
|
400
|
-
HEIGHT: height, #
|
|
401
|
+
HEIGHT: height, #Aro::Config.ivar(:HEIGHT).to_i,
|
|
401
402
|
WIDTH: width - Aro::Mancy::O,
|
|
402
|
-
DIVIDER: :"
|
|
403
|
+
DIVIDER: :".".to_s
|
|
403
404
|
}
|
|
404
405
|
# Aro::V.say(result)
|
|
405
406
|
|
|
@@ -407,57 +408,52 @@ module CLI
|
|
|
407
408
|
end
|
|
408
409
|
|
|
409
410
|
def self.is_format_text?
|
|
410
|
-
|
|
411
|
+
Aro::Config.ivar(:FORMAT)&.to_sym == Aro::Config::FORMATS[:TEXT]
|
|
411
412
|
end
|
|
412
413
|
|
|
413
414
|
def self.process_config_command(args)
|
|
414
|
-
if args[
|
|
415
|
-
|
|
416
|
-
Aro::P.say((
|
|
417
|
-
["config loaded from #{CLI::Config.config_filepath}"] +
|
|
418
|
-
CLI::Config.dump_config
|
|
419
|
-
).join("\n"))
|
|
420
|
-
elsif [args[2],args[3]].compact.any? && args[1] == Aos::Os::CMDS[:CONFIG][:cmds][:SET][:key].to_s
|
|
421
|
-
CLI::Config.set_ivar(args[2], args[3])
|
|
415
|
+
if [args[2],args[3]].compact.any? && args[1] == Aos::Os::CMDS[:CONFIG][:cmds][:SET][:key].to_s
|
|
416
|
+
Aro::Config.set_ivar(args[2], args[3])
|
|
422
417
|
end
|
|
423
418
|
end
|
|
424
419
|
|
|
425
420
|
# out vars
|
|
426
421
|
def self.ovar(suffix)
|
|
427
|
-
|
|
422
|
+
Aro::Config::DEF[suffix][:value]
|
|
428
423
|
end
|
|
429
424
|
# out vars
|
|
430
425
|
def self.ovar_k(suffix)
|
|
431
|
-
"#{
|
|
426
|
+
"#{Aro::Config::ARO_ENV_PREFIX}#{suffix}"
|
|
432
427
|
end
|
|
433
428
|
|
|
434
429
|
# in vars
|
|
435
430
|
def self.ivar(suffix)
|
|
436
|
-
ENV[
|
|
431
|
+
ENV[Aro::Config.ivar_k(suffix)]
|
|
437
432
|
end
|
|
438
433
|
# in vars
|
|
439
434
|
def self.ivar_k(suffix)
|
|
440
|
-
"#{
|
|
435
|
+
"#{Aro::Config::ARO_CONFIG_PREFIX}#{suffix}"
|
|
441
436
|
end
|
|
442
437
|
|
|
443
438
|
def self.set_ivar(k, new_value)
|
|
444
439
|
k = k.upcase.to_sym
|
|
445
440
|
|
|
446
|
-
current_value =
|
|
441
|
+
current_value = Aro::Config.ivar(k)
|
|
447
442
|
# ensure the var name is valid
|
|
448
443
|
unless current_value.nil?
|
|
449
444
|
Aro::Dom::P.say("validating #{k} with value #{new_value}")
|
|
450
|
-
if
|
|
445
|
+
if Aro::Config.instance.valid_var?(new_value, k, Aro::Config::DEF[k])
|
|
451
446
|
# set ENV value
|
|
452
|
-
ENV[
|
|
447
|
+
ENV[Aro::Config.ivar_k(k)] = new_value
|
|
453
448
|
Aro::Dom::P.say("#{k} set to #{new_value}")
|
|
454
|
-
Aro::V.say(ENV[
|
|
449
|
+
Aro::V.say(ENV[Aro::Config.ivar_k(k)])
|
|
455
450
|
|
|
456
451
|
# flush existing config and regen
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
452
|
+
Aro::Config.instance.generate_config(true)
|
|
453
|
+
Aro::Config.instance.source_config
|
|
454
|
+
Aro::Config.instance.setup_env
|
|
455
|
+
Aro::Db.configure_logger
|
|
456
|
+
Aos::Db.configure_logger
|
|
461
457
|
else
|
|
462
458
|
Aro::Dom::P.say("the ivar value you entered is invalid. ignoring.")
|
|
463
459
|
end
|
|
@@ -470,19 +466,19 @@ module CLI
|
|
|
470
466
|
# do not change - update $ARO_CONFIG_ENV .aro/.config file
|
|
471
467
|
#
|
|
472
468
|
# default is production
|
|
473
|
-
varenv =
|
|
474
|
-
is_valid = valid_var?(varenv, :ENV,
|
|
475
|
-
ENV[:ARO_ENV.to_s] = is_valid ? varenv :
|
|
469
|
+
varenv = Aro::Config.ivar(:ENV)
|
|
470
|
+
is_valid = valid_var?(varenv, :ENV, Aro::Config::DEF[:ENV])
|
|
471
|
+
ENV[:ARO_ENV.to_s] = is_valid ? varenv : Aro::Config::ENVS[:PRODUCTION].to_s
|
|
476
472
|
Aro::D.say("setup_env: #{ENV[:ARO_ENV.to_s]}")
|
|
477
473
|
end
|
|
478
474
|
|
|
479
475
|
def self.dump_config
|
|
480
476
|
dump = []
|
|
481
|
-
|
|
482
|
-
if v[:access] ==
|
|
483
|
-
dump << "$#{
|
|
477
|
+
Aro::Config::DEF.each{|k, v|
|
|
478
|
+
if v[:access] == Aro::Config::DEF_ACCESS[:WRITE]
|
|
479
|
+
dump << "$#{Aro::Config.ivar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{Aro::Config.ivar(k)}"
|
|
484
480
|
else
|
|
485
|
-
dump << "$#{
|
|
481
|
+
dump << "$#{Aro::Config.ovar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{Aro::Config.ovar(k)}"
|
|
486
482
|
end
|
|
487
483
|
}
|
|
488
484
|
|
|
@@ -490,9 +486,9 @@ module CLI
|
|
|
490
486
|
end
|
|
491
487
|
|
|
492
488
|
def source_config
|
|
493
|
-
Aro::D.say(I18n.t("cli.config.source", name:
|
|
494
|
-
File.read(
|
|
495
|
-
line.match?(/export #{
|
|
489
|
+
Aro::D.say(I18n.t("cli.config.source", name: Aro::Config.config_filepath))
|
|
490
|
+
File.read(Aro::Config.config_filepath).split("\n").select{|line|
|
|
491
|
+
line.match?(/export #{Aro::Config::ARO_CONFIG_PREFIX}/)
|
|
496
492
|
}.map{|line|
|
|
497
493
|
line.gsub("export ", "").split("=")
|
|
498
494
|
}.each{|kv|
|
|
@@ -503,21 +499,21 @@ module CLI
|
|
|
503
499
|
|
|
504
500
|
# todo: implement
|
|
505
501
|
invalid_defs = validate_config
|
|
506
|
-
|
|
502
|
+
Aro::Config.dump_config.each{|l| Aro::V.say(l)}
|
|
507
503
|
invalid_defs.each{|k|
|
|
508
|
-
v =
|
|
509
|
-
if v[:access] ==
|
|
510
|
-
ENV[
|
|
504
|
+
v = Aro::Config::DEF[k.to_sym]
|
|
505
|
+
if v[:access] == Aro::Config::DEF_ACCESS[:WRITE]
|
|
506
|
+
ENV[Aro::Config.ivar_k(k)] = v[:value]
|
|
511
507
|
else
|
|
512
|
-
ENV[
|
|
508
|
+
ENV[Aro::Config.ovar_k(k)] = v[:value]
|
|
513
509
|
end
|
|
514
510
|
}
|
|
515
511
|
end
|
|
516
512
|
|
|
517
513
|
def generate_config(from_memory = false)
|
|
518
514
|
# todo: localize generated config text
|
|
519
|
-
Aro::D.say(I18n.t("cli.config.generate", name:
|
|
520
|
-
File.open(
|
|
515
|
+
Aro::D.say(I18n.t("cli.config.generate", name: Aro::Config.config_filepath))
|
|
516
|
+
File.open(Aro::Config.config_filepath, "w+") do |file|
|
|
521
517
|
# intro
|
|
522
518
|
Aro::Mancy::OS.times do
|
|
523
519
|
print_div file.object_id
|
|
@@ -550,8 +546,8 @@ module CLI
|
|
|
550
546
|
print_osr file.object_id
|
|
551
547
|
|
|
552
548
|
# vars
|
|
553
|
-
|
|
554
|
-
print_var file.object_id, k, v, (from_memory ? ENV[
|
|
549
|
+
Aro::Config::DEF.each{|k, v|
|
|
550
|
+
print_var file.object_id, k, v, (from_memory ? ENV[Aro::Config.ivar_k(k)] : nil)
|
|
555
551
|
}
|
|
556
552
|
|
|
557
553
|
print_osr file.object_id
|
|
@@ -603,13 +599,13 @@ module CLI
|
|
|
603
599
|
|
|
604
600
|
def print_def_types f_object_id
|
|
605
601
|
file = ObjectSpace._id2ref f_object_id
|
|
606
|
-
file.write("#
|
|
602
|
+
file.write("# Aro::Config::DEF_TYPES\n")
|
|
607
603
|
file.write("# describes the possible types of variables.\n")
|
|
608
|
-
|
|
604
|
+
Aro::Config::DEF_TYPES.each{|k, v|
|
|
609
605
|
file.write("# #{k}: #{v[:description]}\n")
|
|
610
606
|
}
|
|
611
607
|
print_osr f_object_id
|
|
612
|
-
file.write("#
|
|
608
|
+
file.write("# Aro::Config::DEF\n")
|
|
613
609
|
file.write("# define & expose an aro bash api via ENV variables.\n")
|
|
614
610
|
file.write("# there are two types of bash vars in aro.\n")
|
|
615
611
|
file.write("# 1) in vars (ivars). \n")
|
|
@@ -625,25 +621,25 @@ module CLI
|
|
|
625
621
|
def print_var f_object_id, k, v, mem_v
|
|
626
622
|
file = ObjectSpace._id2ref f_object_id
|
|
627
623
|
|
|
628
|
-
is_ovar =
|
|
624
|
+
is_ovar = Aro::Config::DEF[k][:access] == Aro::Config::DEF_ACCESS[:READ]
|
|
629
625
|
if is_ovar
|
|
630
626
|
var_name = k
|
|
631
627
|
else
|
|
632
|
-
var_name =
|
|
628
|
+
var_name = Aro::Config.ivar_k(k)
|
|
633
629
|
end
|
|
634
|
-
Aro::V.say("access for #{k} is #{
|
|
630
|
+
Aro::V.say("access for #{k} is #{Aro::Config::DEF[k][:access]}")
|
|
635
631
|
Aro::V.say("using var_name: #{var_name}")
|
|
636
632
|
file.write("# [#{var_name}] (#{is_ovar ? :ovar : :ivar})\n")
|
|
637
|
-
file.write("# =>
|
|
633
|
+
file.write("# => Aro::Config::DEF_TYPES: #{v[:type]}\n")
|
|
638
634
|
case v[:type]
|
|
639
|
-
when
|
|
635
|
+
when Aro::Config::DEF_TYPES[:INT][:name]
|
|
640
636
|
file.write("# => #{I18n.t("cli.config.type.int_description")}\n")
|
|
641
637
|
file.write("# => #{I18n.t("cli.config.minimum")}: #{v[:min]}\n")
|
|
642
638
|
file.write("# => #{I18n.t("cli.config.maximum")}: #{v[:max]}\n")
|
|
643
|
-
when
|
|
639
|
+
when Aro::Config::DEF_TYPES[:STRING][:name]
|
|
644
640
|
file.write("# => #{I18n.t("cli.config.type.string_description")}\n")
|
|
645
641
|
file.write("# => use \"double quotes\" if there are any spaces.\n")
|
|
646
|
-
when
|
|
642
|
+
when Aro::Config::DEF_TYPES[:VALUES][:name]
|
|
647
643
|
file.write("# => #{I18n.t("cli.config.type.values_description")}\n")
|
|
648
644
|
file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
|
|
649
645
|
print_sr f_object_id
|
|
@@ -657,7 +653,7 @@ module CLI
|
|
|
657
653
|
print_osr f_object_id
|
|
658
654
|
file.write("# => description:\n")
|
|
659
655
|
file.write("# => #{v[:description]}\n")
|
|
660
|
-
if is_ovar &&
|
|
656
|
+
if is_ovar && Aro::Config::DEF_TYPES[:STRING][:name] == v[:type]
|
|
661
657
|
file.write("export #{var_name}=\"#{v[:value]}\"\n")
|
|
662
658
|
else
|
|
663
659
|
file.write("export #{var_name}=#{mem_v || v[:value]}\n")
|