aro 0.1.6 → 0.1.7
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 +5 -5
- data/.ruby-version +1 -1
- data/Gemfile.lock +32 -14
- data/aro.gemspec +16 -7
- data/bin/aro +24 -24
- data/checksums/aro-0.1.6.gem.sha512 +1 -0
- data/listen.rb +10 -0
- data/locale/en.usage.yml +57 -39
- data/locale/en.yml +23 -6
- data/sys/aro/d.rb +25 -0
- data/sys/aro/db.rb +96 -0
- data/sys/aro/mancy.rb +117 -0
- data/sys/aro/p.rb +25 -0
- data/sys/aro/r.rb +20 -0
- data/sys/aro/v.rb +25 -0
- data/sys/aro.rb +15 -0
- data/sys/cli/config.rb +518 -0
- data/sys/cli/constants.rb +53 -0
- data/{bin → sys}/cli/create.rb +6 -4
- data/sys/cli/deck.rb +98 -0
- data/sys/cli/dom.rb +45 -0
- data/sys/cli/nterface.rb +25 -0
- data/{bin → sys}/cli/usage.rb +1 -1
- data/sys/cli.rb +26 -0
- data/sys/dom/d.rb +106 -0
- data/sys/dom/dom.rb +194 -0
- data/sys/dom/p.rb +17 -0
- data/sys/models/deck.rb +212 -0
- data/sys/models/log.rb +10 -0
- data/sys/reiquire.rb +45 -0
- data/{lib/aro → sys/shr}/prompt.rb +11 -3
- data/sys/shr/t.rb +60 -0
- data/sys/shr/version.rb +18 -0
- data/sys/views/base.rb +29 -0
- data/sys/views/dom.rb +27 -0
- data/sys/views/games/deck.rb +97 -0
- data/sys/views/games/menu.rb +27 -0
- data/sys/views/setup/setup.rb +27 -0
- data/tasks/make.rake +2 -2
- metadata +55 -22
- data/.release +0 -20
- data/bin/cli/config.rb +0 -231
- data/bin/cli/constants.rb +0 -39
- data/bin/cli/deck.rb +0 -100
- data/bin/cli.rb +0 -39
- data/lib/aro/c.rb +0 -32
- data/lib/aro/create.rb +0 -29
- data/lib/aro/db.rb +0 -107
- data/lib/aro/environment.rb +0 -3
- data/lib/aro/i18n.rb +0 -12
- data/lib/aro/version.rb +0 -4
- data/lib/aro.rb +0 -45
- data/lib/models/deck.rb +0 -294
- data/lib/models/log.rb +0 -12
data/sys/aro/p.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
p.rb
|
|
4
|
+
|
|
5
|
+
p logger for aro space.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"../shr/prompt".to_s
|
|
12
|
+
require_relative :"./r".to_s
|
|
13
|
+
|
|
14
|
+
module Aro
|
|
15
|
+
class P < Aro::Prompt
|
|
16
|
+
def self.say(message)
|
|
17
|
+
unless Aro::T.is_dev_tarot?
|
|
18
|
+
Aro::R.say(message)
|
|
19
|
+
else
|
|
20
|
+
Aro::P::p.say(">[#{Aro::Mancy::PS1}]>: #{message}")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
data/sys/aro/r.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
r.rb
|
|
4
|
+
|
|
5
|
+
r logger for i2097i.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"../shr/prompt".to_s
|
|
12
|
+
|
|
13
|
+
module Aro
|
|
14
|
+
class R < Aro::Prompt
|
|
15
|
+
def self.say(message)
|
|
16
|
+
Aro::P::p.say(">[#{Aro::T::RUBY_FACOT}]>: #{message}\n")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
data/sys/aro/v.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
v.rb
|
|
4
|
+
|
|
5
|
+
v logger for i2097i.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :d.to_s
|
|
12
|
+
|
|
13
|
+
module Aro
|
|
14
|
+
class V < Aro::D
|
|
15
|
+
def self.say(message)
|
|
16
|
+
return unless Aro::V.should_print?
|
|
17
|
+
Aro::P::p.say(">[Aro::Mancy::DEBUG_VERBOSE]>: #{message}\n")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.should_print?
|
|
21
|
+
Aro::Mancy::DEBUG_VERBOSE && super
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
data/sys/aro.rb
ADDED
data/sys/cli/config.rb
ADDED
|
@@ -0,0 +1,518 @@
|
|
|
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
|
+
DEF_ACCESS = {
|
|
57
|
+
READ: :read,
|
|
58
|
+
WRITE: :write
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
# types used in definition
|
|
62
|
+
#
|
|
63
|
+
# example usage:
|
|
64
|
+
# CLI::Config::DEF_TYPES[:INT][:validator].call(unvalid, CLI::Config::DEF[:DIMENSION])
|
|
65
|
+
DEF_TYPES = {
|
|
66
|
+
INT: {
|
|
67
|
+
name: :int,
|
|
68
|
+
description: I18n.t("cli.config.type_int_description"),
|
|
69
|
+
validator: Proc.new{|unvalid, k, v|
|
|
70
|
+
int_valid = CLI::Config.def_valid?(k, v) &&
|
|
71
|
+
CLI::Config.int_valid?(unvalid) &&
|
|
72
|
+
unvalid.to_i >= v[:min] &&
|
|
73
|
+
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.")
|
|
78
|
+
int_valid
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
STRING: {
|
|
82
|
+
name: :string,
|
|
83
|
+
description: I18n.t("cli.config.type_string_description"),
|
|
84
|
+
validator: Proc.new{|unvalid, k, v|
|
|
85
|
+
unvalid.is_a?(String)
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
VALUES: {
|
|
89
|
+
name: :values,
|
|
90
|
+
description: I18n.t("cli.config.type_values_description"),
|
|
91
|
+
validator: Proc.new{|unvalid, k, v|
|
|
92
|
+
CLI::Config.def_valid?(k, v) &&
|
|
93
|
+
v[:possible_values].keys.include?(unvalid&.to_sym)
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
def self.int_valid?(unvalid)
|
|
99
|
+
!unvalid&.to_i.nil?
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self.def_valid?(key, deff)
|
|
103
|
+
def_valid = deff == CLI::Config::DEF[key]
|
|
104
|
+
unless def_valid
|
|
105
|
+
Aro::V.say("invalid def! #{key} => #{deff}")
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def_valid
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
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)
|
|
115
|
+
}
|
|
116
|
+
invalid_defs
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def validate_value(var_value, k, v)
|
|
120
|
+
CLI::Config::DEF_TYPES[
|
|
121
|
+
v[:type].to_s.upcase.to_sym
|
|
122
|
+
][:validator].call(var_value, k, v)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# adapts I18n translations to generate bash environment vars.
|
|
126
|
+
#
|
|
127
|
+
# example usage:
|
|
128
|
+
# CLI::Config::DEF[:Z_MAX]
|
|
129
|
+
DEF = {
|
|
130
|
+
# writable variables
|
|
131
|
+
ENV: {
|
|
132
|
+
type: :values,
|
|
133
|
+
access: CLI::Config::DEF_ACCESS[:WRITE],
|
|
134
|
+
value: CLI::Config::ENVS[:PRODUCTION],
|
|
135
|
+
description: I18n.t(
|
|
136
|
+
"cli.config.env_description",
|
|
137
|
+
possible_values: CLI::Config::ENVS.values.join(", ")
|
|
138
|
+
),
|
|
139
|
+
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"),
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
FORMAT: { # not implemented yet.
|
|
146
|
+
type: :values,
|
|
147
|
+
implemented: false,
|
|
148
|
+
access: CLI::Config::DEF_ACCESS[:WRITE],
|
|
149
|
+
value: CLI::Config::FORMATS[:TEXT],
|
|
150
|
+
description: I18n.t(
|
|
151
|
+
"cli.config.format_description",
|
|
152
|
+
possible_values: CLI::Config::FORMATS.values.join(", ")
|
|
153
|
+
),
|
|
154
|
+
possible_values: {
|
|
155
|
+
text: I18n.t("cli.config.text_format_description"),
|
|
156
|
+
json: I18n.t("cli.config.json_format_description")
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
DIMENSION: {
|
|
160
|
+
type: :values,
|
|
161
|
+
access: CLI::Config::DEF_ACCESS[:WRITE],
|
|
162
|
+
value: CLI::Config::DMS[:DEV_TAROT],
|
|
163
|
+
description: I18n.t(
|
|
164
|
+
"cli.config.dimension_description",
|
|
165
|
+
possible_values: CLI::Config::DMS.values.join(", ")
|
|
166
|
+
),
|
|
167
|
+
possible_values: {
|
|
168
|
+
dev_tarot: I18n.t("cli.config.dimension_dev_tarot_description"),
|
|
169
|
+
ruby_facot: I18n.t("cli.config.dimension_ruby_facot_description"),
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
DISPLAY_COLUMNS: {
|
|
173
|
+
type: :int,
|
|
174
|
+
access: CLI::Config::DEF_ACCESS[:WRITE],
|
|
175
|
+
value: Aro::Mancy::NUMERALS[:VII],
|
|
176
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
177
|
+
max: Aro::Mancy::NUMERALS[:XXII] / Aro::Mancy::OS,
|
|
178
|
+
description: I18n.t(
|
|
179
|
+
"cli.config.display_columns_description",
|
|
180
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
181
|
+
max: Aro::Mancy::NUMERALS[:XXII] / Aro::Mancy::OS,
|
|
182
|
+
),
|
|
183
|
+
},
|
|
184
|
+
Z: {
|
|
185
|
+
type: :int,
|
|
186
|
+
access: CLI::Config::DEF_ACCESS[:WRITE],
|
|
187
|
+
value: Aro::Mancy::NUMERALS[:I],
|
|
188
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
189
|
+
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
190
|
+
description: I18n.t(
|
|
191
|
+
"cli.config.z_description",
|
|
192
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
193
|
+
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
194
|
+
),
|
|
195
|
+
},
|
|
196
|
+
Z_MAX: {
|
|
197
|
+
type: :int,
|
|
198
|
+
access: CLI::Config::DEF_ACCESS[:WRITE],
|
|
199
|
+
value: Aro::Mancy::NUMERALS[:VII],
|
|
200
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
201
|
+
max: Aro::Mancy::NUMERALS[:XXII],
|
|
202
|
+
description: I18n.t(
|
|
203
|
+
"cli.config.z_max_description",
|
|
204
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
205
|
+
max: Aro::Mancy::NUMERALS[:XXII],
|
|
206
|
+
),
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
# read only variables
|
|
210
|
+
ARO_ENV_O: {
|
|
211
|
+
type: :string,
|
|
212
|
+
access: CLI::Config::DEF_ACCESS[:READ],
|
|
213
|
+
value: Aro::Mancy::O,
|
|
214
|
+
description: I18n.t(
|
|
215
|
+
"cli.config.aro_env_O_description"
|
|
216
|
+
),
|
|
217
|
+
},
|
|
218
|
+
ARO_ENV_S: {
|
|
219
|
+
type: :string,
|
|
220
|
+
access: CLI::Config::DEF_ACCESS[:READ],
|
|
221
|
+
value: Aro::Mancy::S,
|
|
222
|
+
description: I18n.t(
|
|
223
|
+
"cli.config.aro_env_S_description"
|
|
224
|
+
),
|
|
225
|
+
},
|
|
226
|
+
ARO_ENV_OS: {
|
|
227
|
+
type: :string,
|
|
228
|
+
access: CLI::Config::DEF_ACCESS[:READ],
|
|
229
|
+
value: Aro::Mancy::OS,
|
|
230
|
+
description: I18n.t(
|
|
231
|
+
"cli.config.aro_env_OS_description"
|
|
232
|
+
),
|
|
233
|
+
},
|
|
234
|
+
ARO_ENV_N: {
|
|
235
|
+
type: :string,
|
|
236
|
+
access: CLI::Config::DEF_ACCESS[:READ],
|
|
237
|
+
value: Aro::Mancy::N,
|
|
238
|
+
description: I18n.t(
|
|
239
|
+
"cli.config.aro_env_N_description"
|
|
240
|
+
),
|
|
241
|
+
},
|
|
242
|
+
ARO_ENV_PS1: {
|
|
243
|
+
type: :string,
|
|
244
|
+
access: CLI::Config::DEF_ACCESS[:READ],
|
|
245
|
+
value: Aro::Mancy::PS1,
|
|
246
|
+
description: I18n.t(
|
|
247
|
+
"cli.config.aro_env_PS1_description"
|
|
248
|
+
),
|
|
249
|
+
},
|
|
250
|
+
ARO_ENV_NAME_FILE: {
|
|
251
|
+
type: :string,
|
|
252
|
+
access: CLI::Config::DEF_ACCESS[:READ],
|
|
253
|
+
value: Aro::Mancy::NAME_FILE,
|
|
254
|
+
description: I18n.t(
|
|
255
|
+
"cli.config.aro_env_NAME_FILE_description"
|
|
256
|
+
),
|
|
257
|
+
},
|
|
258
|
+
ARO_ENV_I2097I: {
|
|
259
|
+
type: :string,
|
|
260
|
+
access: CLI::Config::DEF_ACCESS[:READ],
|
|
261
|
+
description: I18n.t(
|
|
262
|
+
"cli.config.aro_env_I2097I_description"
|
|
263
|
+
),
|
|
264
|
+
value: Aro::Mancy::I2097I
|
|
265
|
+
},
|
|
266
|
+
ARO_ENV_YES: {
|
|
267
|
+
type: :string,
|
|
268
|
+
access: CLI::Config::DEF_ACCESS[:READ],
|
|
269
|
+
value: Aro::Mancy::YES,
|
|
270
|
+
description: I18n.t(
|
|
271
|
+
"cli.config.aro_env_YES_description"
|
|
272
|
+
),
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
# ...
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
def initialize
|
|
279
|
+
Aro::P.say("config init")
|
|
280
|
+
return unless Aro::Mancy.is_aro_space? && Aro::Mancy.is_initialized?
|
|
281
|
+
unless File.exist?(CLI::Config.config_filepath)
|
|
282
|
+
generate_config
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
source_config
|
|
286
|
+
setup_env
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def self.config_filepath
|
|
290
|
+
File.join(Aro::Db.base_aro_dir, CLI::Config::CONFIG_FILE.to_s)
|
|
291
|
+
end
|
|
292
|
+
|
|
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}")
|
|
306
|
+
|
|
307
|
+
{
|
|
308
|
+
COLUMNS: columns,
|
|
309
|
+
WIDTH: width,
|
|
310
|
+
DIVIDER: :"-".to_s
|
|
311
|
+
}
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# out vars
|
|
315
|
+
def self.ovar(suffix)
|
|
316
|
+
ENV[CLI::Config.ovar_k(suffix)]
|
|
317
|
+
end
|
|
318
|
+
# out vars
|
|
319
|
+
def self.ovar_k(suffix)
|
|
320
|
+
"#{CLI::Config::ARO_ENV_PREFIX}#{suffix}"
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# in vars
|
|
324
|
+
def self.ivar(suffix)
|
|
325
|
+
ENV[CLI::Config.ivar_k(suffix)]
|
|
326
|
+
end
|
|
327
|
+
# in vars
|
|
328
|
+
def self.ivar_k(suffix)
|
|
329
|
+
"#{CLI::Config::ARO_CONFIG_PREFIX}#{suffix}"
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def setup_env
|
|
333
|
+
# do not change - update $ARO_CONFIG_ENV .aro/.config file
|
|
334
|
+
#
|
|
335
|
+
# default is production
|
|
336
|
+
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
|
|
339
|
+
Aro::D.say("setup_env: #{ENV[:ARO_ENV.to_s]}")
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def self.is_test?
|
|
343
|
+
ENV[:ARO_ENV.to_s] == CLI::Config::ENVS[:TEST].to_s
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def source_config
|
|
347
|
+
Aro::D.say(I18n.t("cli.config.sourcing_config", name: CLI::Config.config_filepath))
|
|
348
|
+
File.read(CLI::Config.config_filepath).split("\n").select{|line|
|
|
349
|
+
line.match?(/export #{:ARO_}/)
|
|
350
|
+
}.map{|line|
|
|
351
|
+
line.gsub("export ", "").split("=")
|
|
352
|
+
}.each{|kv|
|
|
353
|
+
Aro::V.say("variable to set: #{kv}")
|
|
354
|
+
ENV[kv[0]] = kv[1] # source
|
|
355
|
+
Aro::V.say("value actually set: #{ENV[kv[0]]}")
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
# todo: implement
|
|
359
|
+
invalid_defs = validate_config
|
|
360
|
+
CLI::Config::DEF.keys.each{|dfk|
|
|
361
|
+
Aro::V.say("$#{CLI::Config.ivar_k(dfk)}=#{CLI::Config.ivar(dfk)}")
|
|
362
|
+
}
|
|
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
|
+
end
|
|
369
|
+
|
|
370
|
+
def generate_config
|
|
371
|
+
# todo: localize generated config text
|
|
372
|
+
Aro::D.say(I18n.t("cli.config.generating_default_config", name: CLI::Config.config_filepath))
|
|
373
|
+
File.open(CLI::Config.config_filepath, "w+") do |file|
|
|
374
|
+
# intro
|
|
375
|
+
Aro::Mancy::OS.times do
|
|
376
|
+
print_div file.object_id
|
|
377
|
+
end
|
|
378
|
+
# header
|
|
379
|
+
print_div file.object_id
|
|
380
|
+
print_sr file.object_id
|
|
381
|
+
print_config_header file.object_id
|
|
382
|
+
print_sr file.object_id
|
|
383
|
+
print_div file.object_id
|
|
384
|
+
|
|
385
|
+
print_osr file.object_id
|
|
386
|
+
|
|
387
|
+
# def_types
|
|
388
|
+
print_div file.object_id
|
|
389
|
+
print_sr file.object_id
|
|
390
|
+
print_def_types file.object_id
|
|
391
|
+
print_sr file.object_id
|
|
392
|
+
print_div file.object_id
|
|
393
|
+
|
|
394
|
+
print_osr file.object_id
|
|
395
|
+
|
|
396
|
+
# var section
|
|
397
|
+
print_div file.object_id
|
|
398
|
+
print_sr file.object_id
|
|
399
|
+
print_var_section file.object_id
|
|
400
|
+
print_sr file.object_id
|
|
401
|
+
print_div file.object_id
|
|
402
|
+
|
|
403
|
+
print_osr file.object_id
|
|
404
|
+
|
|
405
|
+
# vars
|
|
406
|
+
CLI::Config::DEF.each{|k, v|
|
|
407
|
+
print_var file.object_id, k, v
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
print_osr file.object_id
|
|
411
|
+
|
|
412
|
+
# var section
|
|
413
|
+
print_div file.object_id
|
|
414
|
+
print_sr file.object_id
|
|
415
|
+
print_var_section file.object_id
|
|
416
|
+
print_sr file.object_id
|
|
417
|
+
print_div file.object_id
|
|
418
|
+
|
|
419
|
+
print_osr file.object_id
|
|
420
|
+
# outro
|
|
421
|
+
Aro::Mancy::OS.times do
|
|
422
|
+
print_div file.object_id
|
|
423
|
+
end
|
|
424
|
+
file.write("\n")
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def print_div f_object_id
|
|
429
|
+
file = ObjectSpace._id2ref f_object_id
|
|
430
|
+
file.write("#{"#" * Aro::Mancy::NUMERALS[:VIII].pow(2)}\n")
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def print_sr f_object_id
|
|
434
|
+
file = ObjectSpace._id2ref f_object_id
|
|
435
|
+
Aro::Mancy::S.times do
|
|
436
|
+
file.write("#\n")
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def print_osr f_object_id
|
|
441
|
+
Aro::Mancy::OS.times do
|
|
442
|
+
print_sr f_object_id
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def print_config_header f_object_id
|
|
447
|
+
file = ObjectSpace._id2ref f_object_id
|
|
448
|
+
file.write("# #{Aro::Mancy::PS1} configuration file.\n")
|
|
449
|
+
file.write("# this file was auto generated by the aro cli.\n")
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
def print_var_section f_object_id
|
|
453
|
+
file = ObjectSpace._id2ref f_object_id
|
|
454
|
+
file.write("# VARIABLE SECTION!\n")
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
def print_def_types f_object_id
|
|
458
|
+
file = ObjectSpace._id2ref f_object_id
|
|
459
|
+
file.write("# CLI::Config::DEF_TYPES\n")
|
|
460
|
+
file.write("# describes the possible types of variables.\n")
|
|
461
|
+
CLI::Config::DEF_TYPES.each{|k, v|
|
|
462
|
+
file.write("# #{k}: #{v[:description]}\n")
|
|
463
|
+
}
|
|
464
|
+
print_osr f_object_id
|
|
465
|
+
file.write("# CLI::Config::DEF\n")
|
|
466
|
+
file.write("# define & expose an aro bash api via ENV variables.\n")
|
|
467
|
+
file.write("# there are two types of bash vars in aro.\n")
|
|
468
|
+
file.write("# 1) in vars (ivars). \n")
|
|
469
|
+
file.write("# => ivars enter aro from this file during aro init.\n")
|
|
470
|
+
file.write("# => aro validates them and uses them unless unvalid.\n")
|
|
471
|
+
file.write("# => otherwise aro will use the defaults listed below.\n")
|
|
472
|
+
file.write("# 2) out vars (ovars).\n")
|
|
473
|
+
file.write("# => ovars are read-only vars that aro exposes to bash.\n")
|
|
474
|
+
file.write("# => this is useful because it provides a bash interface\n")
|
|
475
|
+
file.write("# => which can be used to write programs on top of aro.\n")
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
def print_var f_object_id, k, v
|
|
479
|
+
file = ObjectSpace._id2ref f_object_id
|
|
480
|
+
|
|
481
|
+
is_ovar = CLI::Config::DEF[k][:access] == CLI::Config::DEF_ACCESS[:READ]
|
|
482
|
+
if is_ovar
|
|
483
|
+
var_name = k
|
|
484
|
+
else
|
|
485
|
+
var_name = CLI::Config.ivar_k(k)
|
|
486
|
+
end
|
|
487
|
+
Aro::V.say("access for #{k} is #{CLI::Config::DEF[k][:access]}")
|
|
488
|
+
Aro::V.say("using var_name: #{var_name}")
|
|
489
|
+
file.write("# [#{var_name}] (#{is_ovar ? :ovar : :ivar})\n")
|
|
490
|
+
file.write("# => #{I18n.t("cli.config.def_type")}: #{v[:type]}\n")
|
|
491
|
+
case v[:type]
|
|
492
|
+
when CLI::Config::DEF_TYPES[:INT][:name]
|
|
493
|
+
file.write("# => #{I18n.t("cli.config.type_int_description")}\n")
|
|
494
|
+
file.write("# => #{I18n.t("cli.config.minimum")}: #{v[:min]}\n")
|
|
495
|
+
file.write("# => #{I18n.t("cli.config.maximum")}: #{v[:max]}\n")
|
|
496
|
+
when CLI::Config::DEF_TYPES[:STRING][:name]
|
|
497
|
+
file.write("# => #{I18n.t("cli.config.type_string_description")}\n")
|
|
498
|
+
file.write("# => use \"double quotes\" if there are any spaces.\n")
|
|
499
|
+
when CLI::Config::DEF_TYPES[:VALUES][:name]
|
|
500
|
+
file.write("# => #{I18n.t("cli.config.type_values_description")}\n")
|
|
501
|
+
file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
|
|
502
|
+
print_sr f_object_id
|
|
503
|
+
v[:possible_values].each{|name, description|
|
|
504
|
+
file.write("# => #{name}\n")
|
|
505
|
+
print_sr f_object_id
|
|
506
|
+
file.write("# =>#{description}\n")
|
|
507
|
+
print_sr f_object_id
|
|
508
|
+
}
|
|
509
|
+
end
|
|
510
|
+
print_osr f_object_id
|
|
511
|
+
file.write("# => description:\n")
|
|
512
|
+
file.write("# => #{v[:description]}\n")
|
|
513
|
+
file.write("export #{var_name}=#{v[:value]}\n")
|
|
514
|
+
print_osr f_object_id
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
end
|
|
518
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
ARO: {
|
|
28
|
+
CREATE: :create,
|
|
29
|
+
CONFIG: :config,
|
|
30
|
+
DECK: :deck,
|
|
31
|
+
DOM: :dom,
|
|
32
|
+
INIT: :init,
|
|
33
|
+
},
|
|
34
|
+
CONFIG: {
|
|
35
|
+
# ...
|
|
36
|
+
},
|
|
37
|
+
DECK: {
|
|
38
|
+
DRAW: :draw,
|
|
39
|
+
EXPLORE: :explore,
|
|
40
|
+
NEW: :new,
|
|
41
|
+
REPLACE: :replace,
|
|
42
|
+
RESET: :reset,
|
|
43
|
+
SHOW: :show,
|
|
44
|
+
SHUFFLE: :shuffle,
|
|
45
|
+
},
|
|
46
|
+
DOM: {
|
|
47
|
+
INIT: :init,
|
|
48
|
+
MAP: :map,
|
|
49
|
+
NEW: :new,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
end
|
data/{bin → sys}/cli/create.rb
RENAMED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
aro.rb
|
|
4
4
|
|
|
5
|
-
process aro
|
|
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::
|
|
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::
|
|
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))
|