aro 0.2.1 → 0.2.3
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 +1 -1
- data/README.md +1 -1
- data/aro.gemspec +3 -3
- data/bin/aos +10 -3
- data/bin/aro +18 -11
- data/checksums/aro-0.2.1.gem.sha512 +1 -0
- data/checksums/aro-0.2.2.gem.sha512 +1 -0
- data/checksums/aro-0.2.3.gem.sha512 +1 -0
- data/locale/en.abot.yml +81 -0
- data/locale/en.amg.yml +44 -0
- data/locale/en.aos.yml +8 -38
- data/locale/en.cor.yml +47 -0
- data/locale/en.data.yml +30 -0
- data/locale/en.dom.yml +22 -18
- data/locale/en.flie.yml +29 -0
- data/locale/en.usage.yml +39 -26
- data/locale/en.yml +10 -51
- data/sys/aos/abot.rb +256 -0
- data/sys/aos/amg.rb +58 -56
- data/sys/aos/aos.rb +425 -180
- data/sys/aos/cor.rb +773 -0
- data/sys/aos/data.rb +117 -0
- data/sys/aos/db/migrate/1765148774_create_yous.rb +1 -0
- data/sys/aos/db/migrate/{1765762724_create_libs.rb → 1765762724_create_ilibs.rb} +5 -5
- data/sys/aos/db/migrate/1765907766_create_ilogs.rb +18 -0
- data/sys/aos/db/migrate/1765933985_create_agodos.rb +22 -0
- data/sys/aos/db/migrate/1766203888_create_fpxies.rb +18 -0
- data/sys/aos/db.rb +47 -27
- data/sys/aos/flie.rb +144 -0
- data/sys/aos/models/agodo.rb +96 -0
- data/sys/aos/models/base_model.rb +13 -0
- data/sys/aos/models/fpxy.rb +28 -0
- data/sys/{shr/lib/lib.rb → aos/models/ilib.rb} +11 -6
- data/sys/aos/models/ilog.rb +29 -0
- data/sys/aos/models/you.rb +98 -0
- data/sys/aos/s.rb +2 -1
- data/sys/aos/vws/base.rb +69 -78
- data/sys/aos/vws/dom.rb +1 -2
- data/sys/aos/vws/games/abot.rb +21 -0
- data/sys/aos/vws/games/{game.rb → teck.rb} +27 -24
- data/sys/aos/vws/home.rb +23 -0
- data/sys/aos/vws/know/{temple.rb → body.rb} +3 -3
- data/sys/aos/vws/know/{library.rb → mind.rb} +3 -3
- data/sys/aos/vws/know/spirit.rb +19 -0
- data/sys/aos/vws/{setup → root}/amg.rb +1 -2
- data/sys/aos/vws/{setup → root}/config.rb +4 -4
- data/sys/aos/vws/root/data.rb +21 -0
- data/sys/aos/vws/root/flie.rb +21 -0
- data/sys/aos/vws/{setup.rb → root.rb} +3 -3
- data/sys/aos/vws/welcome/waite.rb +1 -0
- data/sys/aos/vws/welcome.rb +47 -0
- data/sys/aro/d.rb +4 -2
- data/sys/aro/db/migrate/{1763374647_create_decks.rb → 1763374647_create_tecks.rb} +5 -5
- data/sys/aro/db/migrate/1763432541_create_tlogs.rb +20 -0
- data/sys/aro/db.rb +28 -19
- data/sys/aro/mancy.rb +18 -22
- data/sys/aro/models/base_model.rb +13 -0
- data/sys/{models/deck.rb → aro/models/teck.rb} +60 -57
- data/sys/aro/models/tlog.rb +21 -0
- data/sys/aro/p.rb +1 -1
- data/sys/aro/r.rb +2 -1
- data/sys/aro/v.rb +2 -2
- data/sys/cli/constants.rb +4 -10
- data/sys/cli/create.rb +2 -3
- data/sys/cli/dom.rb +1 -2
- data/sys/cli/{deck.rb → teck.rb} +38 -45
- data/sys/cli.rb +10 -11
- data/sys/dom/d.rb +68 -46
- data/sys/dom/dom.rb +79 -44
- data/sys/dom/p.rb +1 -1
- data/sys/fpx.rb +116 -0
- data/sys/reiquire.rb +8 -8
- data/sys/shr/prompt.rb +2 -6
- data/sys/shr/t.rb +11 -13
- data/sys/shr/version.rb +1 -1
- data/tasks/make.rake +1 -1
- metadata +82 -62
- data/locale/en.cngelog.yml +0 -5
- data/sys/aos/vws/games/abpps.rb +0 -19
- data/sys/aos/vws/games/hbpps.rb +0 -19
- data/sys/aos/vws/games/shpps.rb +0 -19
- data/sys/aos/vws/games/vipps.rb +0 -19
- data/sys/aos/you.rb +0 -21
- data/sys/aro/db/migrate/1763432541_create_logs.rb +0 -20
- data/sys/dom/config.rb +0 -665
- data/sys/models/log.rb +0 -20
- /data/sys/shr/{lib → ilib}/crs/CMakeLists.txt +0 -0
- /data/sys/shr/{lib → ilib}/crs/compile.sh +0 -0
- /data/sys/shr/{lib → ilib}/crs/crs.c +0 -0
- /data/sys/shr/{lib → ilib}/crs/crs.o +0 -0
- /data/sys/shr/{lib → ilib}/crs/libcrs.so +0 -0
data/sys/aos/aos.rb
CHANGED
|
@@ -26,19 +26,50 @@ module Aos
|
|
|
26
26
|
Aos::Os::instance.process_cmd(cmd)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
def self.fpx
|
|
30
|
+
require_relative :"../fpx".to_s
|
|
31
|
+
if ARGV[Aro::Mancy::S].nil?
|
|
32
|
+
Aos::Fpx::Server.start
|
|
33
|
+
return
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
case ARGV[Aro::Mancy::S].to_sym
|
|
37
|
+
when :restart
|
|
38
|
+
Aos::Fpx::Server.stop
|
|
39
|
+
sleep(Aro::Mancy::S)
|
|
40
|
+
Aos::Fpx::Server.start
|
|
41
|
+
when :stop
|
|
42
|
+
Aos::Fpx::Server.stop
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
29
46
|
class Os
|
|
30
47
|
include Singleton
|
|
31
48
|
|
|
32
|
-
attr_accessor :
|
|
49
|
+
attr_accessor :display_lines,
|
|
50
|
+
:q,
|
|
51
|
+
:running,
|
|
52
|
+
:stream_pid,
|
|
53
|
+
:view,
|
|
54
|
+
:you,
|
|
55
|
+
:you_flag
|
|
33
56
|
|
|
34
57
|
A = :"@"
|
|
35
58
|
STAR = :"*"
|
|
36
59
|
YOU = :you.to_s
|
|
37
60
|
YOU_FLAG = :"--you".to_s
|
|
61
|
+
DB_POOL = Aro::Mancy::NUMERALS[:XLII]
|
|
38
62
|
PS1 = :">[#{Aos::Os}]>: "
|
|
63
|
+
Q_PID = :"q.pid"
|
|
64
|
+
Q_UP = :"q.up"
|
|
39
65
|
DATE_FORMAT = "%A %d %b %Y %I:%M:%S %p"
|
|
40
66
|
|
|
41
67
|
CMDS = {
|
|
68
|
+
ABOT: {
|
|
69
|
+
key: :abot,
|
|
70
|
+
description: I18n.t("aos.commands.description.abot"),
|
|
71
|
+
usage: I18n.t("aos.commands.usage.abot"),
|
|
72
|
+
},
|
|
42
73
|
AMG: {
|
|
43
74
|
key: :amg,
|
|
44
75
|
description: I18n.t("aos.commands.description.amg"),
|
|
@@ -49,23 +80,26 @@ module Aos
|
|
|
49
80
|
description: I18n.t("aos.commands.description.cd"),
|
|
50
81
|
usage: I18n.t("aos.commands.usage.cd"),
|
|
51
82
|
},
|
|
52
|
-
|
|
53
|
-
key: :
|
|
54
|
-
description: I18n.t("aos.commands.description.
|
|
55
|
-
usage: I18n.t("aos.commands.usage.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
83
|
+
COR: {
|
|
84
|
+
key: :cor,
|
|
85
|
+
description: I18n.t("aos.commands.description.cor"),
|
|
86
|
+
usage: I18n.t("aos.commands.usage.cor"),
|
|
87
|
+
},
|
|
88
|
+
DATA: {
|
|
89
|
+
key: :data,
|
|
90
|
+
description: I18n.t("aos.commands.description.data"),
|
|
91
|
+
usage: I18n.t("aos.commands.usage.data"),
|
|
63
92
|
},
|
|
64
93
|
EXIT: {
|
|
65
94
|
key: :exit,
|
|
66
95
|
description: I18n.t("aos.commands.description.exit"),
|
|
67
96
|
usage: I18n.t("aos.commands.usage.exit"),
|
|
68
97
|
},
|
|
98
|
+
FLIE: {
|
|
99
|
+
key: :flie,
|
|
100
|
+
description: I18n.t("aos.commands.description.flie"),
|
|
101
|
+
usage: I18n.t("aos.commands.usage.flie"),
|
|
102
|
+
},
|
|
69
103
|
HELP: {
|
|
70
104
|
key: :help,
|
|
71
105
|
description: I18n.t("aos.commands.description.help"),
|
|
@@ -91,7 +125,9 @@ module Aos
|
|
|
91
125
|
def self.osify(path, leading_slash = false)
|
|
92
126
|
return path unless Aro::Dom.in_arodom?
|
|
93
127
|
path_arr = path.split("/")
|
|
94
|
-
Aro::Dom::dom_root.split("/").each{|rdp|
|
|
128
|
+
Aro::Dom::dom_root.split("/").each{|rdp|
|
|
129
|
+
path_arr.delete_at(path_arr.index(rdp)) unless path_arr.index(rdp).nil?
|
|
130
|
+
}
|
|
95
131
|
result = path_arr.join("/")
|
|
96
132
|
if leading_slash
|
|
97
133
|
result = "/" + result
|
|
@@ -102,72 +138,95 @@ module Aos
|
|
|
102
138
|
|
|
103
139
|
def self.is_aos_command?(arg)
|
|
104
140
|
# determine if command is Aos::Os::CMDS
|
|
105
|
-
# passthrough to system if command is not in Aos::Os::CMDS
|
|
106
141
|
Aos::Os::CMDS.values.map{|v| v[:key]}.include?(arg.to_sym)
|
|
107
142
|
end
|
|
108
143
|
|
|
109
|
-
def self.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if cmd.present? && cmd.include?(Aos::Os::YOU_FLAG)
|
|
115
|
-
cmd_split = cmd.split(" ")
|
|
116
|
-
i = cmd_split.index(Aos::Os::YOU_FLAG)
|
|
117
|
-
cmd_split.delete_at(i)
|
|
118
|
-
cmd_split.delete_at(i)
|
|
119
|
-
cmd = cmd_split.join(" ")
|
|
144
|
+
def self.sanitize_you(args = [])
|
|
145
|
+
if args.any? && args.include?(Aos::Os::YOU_FLAG)
|
|
146
|
+
i = args.index(Aos::Os::YOU_FLAG)
|
|
147
|
+
args.delete_at(i)
|
|
148
|
+
args.delete_at(i)
|
|
120
149
|
end
|
|
121
150
|
|
|
122
|
-
|
|
151
|
+
args
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def self.cron
|
|
155
|
+
Aos::Abot.cron
|
|
156
|
+
# ...
|
|
123
157
|
end
|
|
124
158
|
|
|
125
159
|
def initialize
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
end
|
|
130
|
-
@db = Aos::Db.new
|
|
131
|
-
load_libs
|
|
132
|
-
load_you
|
|
160
|
+
Aos::Db.load
|
|
161
|
+
load_ilibs
|
|
162
|
+
Aos::Abot.abot
|
|
133
163
|
end
|
|
134
164
|
|
|
135
|
-
def
|
|
136
|
-
# todo: load from directory of
|
|
165
|
+
def load_ilibs
|
|
166
|
+
# todo: load from directory of ilibs.
|
|
137
167
|
# something like:
|
|
138
168
|
#
|
|
139
|
-
# Dir[lib_something_something].each do{|l| Aos::
|
|
169
|
+
# Dir[lib_something_something].each do{|l| Aos::Ilib.install(l)}
|
|
140
170
|
|
|
141
171
|
# for now static
|
|
142
172
|
Aos::Amg.load(:crs)
|
|
143
173
|
end
|
|
144
174
|
|
|
145
|
-
def
|
|
146
|
-
|
|
175
|
+
def self.you_name_from_flag_arg
|
|
176
|
+
yfi = ARGV.index(Aos::Os::YOU_FLAG)
|
|
177
|
+
return ARGV[yfi + Aro::Mancy::S]&.strip unless yfi.nil?
|
|
178
|
+
end
|
|
147
179
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
180
|
+
Mutex.new.synchronize do
|
|
181
|
+
def load_you!
|
|
182
|
+
self.you_flag = nil
|
|
183
|
+
self.you = Aos::You.find_by(access: :root)
|
|
184
|
+
if ARGV.include?(Aos::Os::YOU_FLAG)
|
|
185
|
+
you_name = Aos::Os.you_name_from_flag_arg
|
|
186
|
+
unless you_name == self.you.name
|
|
187
|
+
self.you = Aos::You.find_by(name: you_name)
|
|
188
|
+
if self.you.nil?
|
|
189
|
+
self.you = Aos::You.create(name: you_name)
|
|
190
|
+
self.you.reload
|
|
191
|
+
end
|
|
192
|
+
self.you_flag = self.you
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
Aro::V.say("you loaded:\n#{caller[Aro::Mancy::O..Aro::Mancy::N].join("\n")}")
|
|
197
|
+
Aro::V.say(self.you.name)
|
|
198
|
+
Aro::V.say(Aos::Os.osify(self.you.pwd))
|
|
151
199
|
end
|
|
200
|
+
end
|
|
152
201
|
|
|
153
|
-
|
|
154
|
-
|
|
202
|
+
def load_you
|
|
203
|
+
return unless self.you_flag.nil?
|
|
204
|
+
load_you!
|
|
205
|
+
end
|
|
155
206
|
|
|
156
|
-
|
|
207
|
+
def get_pwd_for(you_name)
|
|
208
|
+
Aos::You.find_by(name: you_name)&.pwd
|
|
157
209
|
end
|
|
158
210
|
|
|
159
211
|
def load_view
|
|
160
|
-
view_name = Aos::Os.osify(
|
|
212
|
+
view_name = Aos::Os.osify(self.you.pwd).split("/").last || :dom.to_s
|
|
161
213
|
view_cls = nil
|
|
162
|
-
begin
|
|
163
|
-
view_cls = (Aos::Vw.name + "::#{view_name.capitalize}").constantize
|
|
164
|
-
rescue
|
|
165
|
-
view_cls = Aos::Vw::Base
|
|
166
|
-
end
|
|
167
214
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
215
|
+
if self.you.home?
|
|
216
|
+
view_cls = Aos::Vw::Home
|
|
217
|
+
else
|
|
218
|
+
cls_name = (Aos::Vw.name + "::#{view_name.capitalize}")
|
|
219
|
+
Aro::D.say("attempting to load view class #{cls_name}")
|
|
220
|
+
begin
|
|
221
|
+
view_cls = cls_name.constantize
|
|
222
|
+
rescue
|
|
223
|
+
view_cls = Aos::Vw::Base
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
Dir.chdir(self.you.pwd) do
|
|
227
|
+
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
228
|
+
view_cls = Aos::Vw::Teck
|
|
229
|
+
end
|
|
171
230
|
end
|
|
172
231
|
end
|
|
173
232
|
|
|
@@ -175,32 +234,161 @@ module Aos
|
|
|
175
234
|
@view = view_cls
|
|
176
235
|
end
|
|
177
236
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
237
|
+
Mutex.new.synchronize do
|
|
238
|
+
def render
|
|
239
|
+
load_view
|
|
240
|
+
return if @view.nil?
|
|
241
|
+
|
|
242
|
+
Dir.chdir(self.you.reload.pwd) do
|
|
243
|
+
if Aro::Mancy.in_aro?
|
|
244
|
+
Aro::Mancy.init
|
|
245
|
+
if Aro::Mancy.is_initialized? && !Aro::Mancy.teck.nil?
|
|
246
|
+
Aro::Mancy.teck.show
|
|
247
|
+
end
|
|
248
|
+
else
|
|
249
|
+
@view.show
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def self.q
|
|
256
|
+
self.instance.q
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
Mutex.new.synchronize do
|
|
260
|
+
def self.say(lines)
|
|
261
|
+
unless Aro::Dom.is_initialized?
|
|
262
|
+
Aos::S.say(lines.join("\n"))
|
|
263
|
+
return
|
|
264
|
+
end
|
|
265
|
+
Aos::Db.load
|
|
266
|
+
current_you = self.instance.you_flag || self.instance.you
|
|
267
|
+
lines = [lines] unless lines.kind_of?(Array)
|
|
268
|
+
if current_you.nil?
|
|
269
|
+
Aos::S.say(lines.join("\n"))
|
|
184
270
|
else
|
|
185
|
-
|
|
271
|
+
# Mutex.new.synchronize do
|
|
272
|
+
Aos::Os.instance.q ||= {}
|
|
273
|
+
Aos::Os.q[current_you.name] ||= []
|
|
274
|
+
Aos::Os.q[current_you.name] += lines
|
|
275
|
+
# Aos::S.say("adding lines to #{current_you.name} (#{lines.count})")
|
|
276
|
+
# Aos::S.say("total: #{Aos::Os.q[current_you.name].count})")
|
|
277
|
+
# Aos::Os.streamq unless File.exist?(Aos::Os.q_pid_file)
|
|
278
|
+
Aos::Os.q.keys.each{|you_name|
|
|
279
|
+
current_you = Aos::You.find_by(
|
|
280
|
+
name: you_name
|
|
281
|
+
)
|
|
282
|
+
# Aos::S.say("streaming #{Aos::Os.q[you_name].count} lines to #{current_you.name}")
|
|
283
|
+
current_you.stream(
|
|
284
|
+
Aos::Os.q.delete(you_name)
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
# end
|
|
186
288
|
end
|
|
187
289
|
end
|
|
188
290
|
end
|
|
189
291
|
|
|
292
|
+
# def self.streamq
|
|
293
|
+
# return unless !Aos::Cor.is_test? && self.instance.stream_pid.nil?
|
|
294
|
+
# puts self.instance.q.inspect
|
|
295
|
+
# Mutex.new.synchronize do
|
|
296
|
+
# self.instance.stream_pid = fork {
|
|
297
|
+
# loop do
|
|
298
|
+
# sleep(Aro::Mancy::OS)
|
|
299
|
+
|
|
300
|
+
# Aos::S.say("processing streamq #{self.instance.q.inspect}...")
|
|
301
|
+
# Aos::Db.load
|
|
302
|
+
# next if Aos::Os.q.nil?
|
|
303
|
+
# qdup = Aos::Os.q.keys.dup
|
|
304
|
+
# qdup.each{|you_name|
|
|
305
|
+
# current_you = Aos::You.find_by(
|
|
306
|
+
# name: you_name
|
|
307
|
+
# )
|
|
308
|
+
# Aos::S.say("streaming #{Aos::Os.q[you_name].count} lines to #{current_you.name}")
|
|
309
|
+
# current_you.stream(
|
|
310
|
+
# Aos::Os.q.delete(you_name)
|
|
311
|
+
# )
|
|
312
|
+
# }
|
|
313
|
+
# end
|
|
314
|
+
# }
|
|
315
|
+
# end
|
|
316
|
+
# Process.detach(self.instance.stream_pid)
|
|
317
|
+
# File.open(Aos::Os.q_pid_file, "w") do |f|
|
|
318
|
+
# f.write(self.instance.stream_pid)
|
|
319
|
+
# end
|
|
320
|
+
# end
|
|
321
|
+
|
|
322
|
+
# def self.q_pid_file
|
|
323
|
+
# File.join(Aos::Cor.dom_cor_path, Aos::Os::Q_PID.to_s)
|
|
324
|
+
# end
|
|
325
|
+
|
|
326
|
+
# def self.q_up_file
|
|
327
|
+
# File.join(Aos::Cor.dom_cor_path, Aos::Os::Q_UP.to_s)
|
|
328
|
+
# end
|
|
329
|
+
|
|
330
|
+
# def self.read_q_up
|
|
331
|
+
# # return unless Aro::Dom.is_initialized?
|
|
332
|
+
# # Aos::You.pluck(:name).each{|you_name|
|
|
333
|
+
# # q_up_file = Aos::Os.q_up_file_for_you(you_name)
|
|
334
|
+
# # if File.exist?(q_up_file)
|
|
335
|
+
# # self.instance.q[you_name] = JSON.parse(File.read(q_up_file))
|
|
336
|
+
# # end
|
|
337
|
+
# # }
|
|
338
|
+
# end
|
|
339
|
+
|
|
340
|
+
# def self.write_q_up
|
|
341
|
+
# self.instance.q.keys.each{|you_name|
|
|
342
|
+
# File.open(Aos::Os.q_up_file_for_you(you_name), "w") do |q_up|
|
|
343
|
+
# q_up.write(self.instance.q[you_name].to_json)
|
|
344
|
+
# end
|
|
345
|
+
# }
|
|
346
|
+
# end
|
|
347
|
+
|
|
348
|
+
# def self.q_up_file_for_you(you_name)
|
|
349
|
+
# "#{you_name}.#{Aos::Os.q_up_file}"
|
|
350
|
+
# end
|
|
351
|
+
|
|
352
|
+
# def self.terminateq
|
|
353
|
+
# qpf = Aos::Os.q_pid_file
|
|
354
|
+
# if File.exist?(qpf)
|
|
355
|
+
# system("kill -9 #{File.read(qpf)}")
|
|
356
|
+
# FileUtils.rm(qpf)
|
|
357
|
+
# # Aos::Os.write_q_up
|
|
358
|
+
# end
|
|
359
|
+
# end
|
|
360
|
+
|
|
361
|
+
def handle_aro_override(args)
|
|
362
|
+
return nil unless args[0].include?(:aro.to_s)
|
|
363
|
+
# !self.you_flag.nil?
|
|
364
|
+
yfi = args.index(Aos::Os::YOU_FLAG)
|
|
365
|
+
if yfi.nil?
|
|
366
|
+
args = "#{args.join(" ")} #{:aos.to_s} #{Aos::Os::YOU_FLAG} #{self.you.name}".split(" ")
|
|
367
|
+
else
|
|
368
|
+
args.insert(yfi, :aos.to_s)
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
`#{args.join(" ")}`
|
|
372
|
+
end
|
|
373
|
+
|
|
190
374
|
def process_cmd(cmd)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
end
|
|
375
|
+
# load config
|
|
376
|
+
Aos::Cor.instance.load
|
|
377
|
+
load_you!
|
|
378
|
+
Dir.chdir(self.you.reload.pwd) do
|
|
379
|
+
send_to_system_call = main(cmd)
|
|
197
380
|
nothing = nil
|
|
198
|
-
|
|
199
|
-
nothing =
|
|
200
|
-
|
|
381
|
+
unless cmd.nil? || cmd.empty?
|
|
382
|
+
nothing = handle_aro_override(cmd.split(" "))
|
|
383
|
+
self.you.generate_ilog(cmd)
|
|
384
|
+
end
|
|
385
|
+
if send_to_system_call && nothing.nil?
|
|
386
|
+
nothing = `#{cmd}`
|
|
201
387
|
end
|
|
202
388
|
|
|
203
|
-
|
|
389
|
+
unless nothing.nil?
|
|
390
|
+
Aos::Os.say(nothing)
|
|
391
|
+
else
|
|
204
392
|
render
|
|
205
393
|
end
|
|
206
394
|
end
|
|
@@ -208,48 +396,54 @@ module Aos
|
|
|
208
396
|
CLI::EXIT_CODES[:SUCCESS]
|
|
209
397
|
end
|
|
210
398
|
|
|
211
|
-
def configure_readline
|
|
212
|
-
#
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
399
|
+
def configure_readline(env)
|
|
400
|
+
# case env
|
|
401
|
+
# when :home
|
|
402
|
+
Readline.completion_append_character = "/"
|
|
403
|
+
Readline.completion_proc = Proc.new{|str|
|
|
404
|
+
pwd = self.you_flag&.reload&.pwd || self.you&.reload&.pwd || ""
|
|
405
|
+
dir_matcher = File.join(pwd, str + Aos::Os::STAR.to_s)
|
|
406
|
+
# Aro::V.say(dir_matcher)
|
|
407
|
+
dir_listing = Dir.glob(dir_matcher, File::FNM_DOTMATCH).map{|d| Aos::Os.osify(d).split("/").reject{|p| pwd.include?(p)}.join("/")}
|
|
408
|
+
# Aro::V.say(dir_listing)
|
|
409
|
+
dir_listing.grep(/^#{Regexp.escape(str)}/)
|
|
410
|
+
}
|
|
411
|
+
# when :aos
|
|
412
|
+
# Readline.completion_append_character = "/"
|
|
413
|
+
# Readline.completion_proc = Proc.new{|str|
|
|
414
|
+
# Aro::Dom::D.reserved_words.grep(/^#{Regexp.escape(str)}/)
|
|
415
|
+
# }
|
|
416
|
+
# end
|
|
230
417
|
end
|
|
231
418
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
419
|
+
Mutex.new.synchronize do
|
|
420
|
+
def run
|
|
421
|
+
# run condition
|
|
422
|
+
self.running = true
|
|
423
|
+
|
|
424
|
+
# start cron
|
|
425
|
+
Aos::Os.cron
|
|
426
|
+
|
|
427
|
+
original_stdout = $stdout
|
|
428
|
+
$stdout = StringIO.open do |out|
|
|
429
|
+
cmd = nil
|
|
430
|
+
|
|
431
|
+
loop do
|
|
432
|
+
configure_readline :aos
|
|
433
|
+
break unless self.running && cmd = Readline.readline(calc_ps1)
|
|
434
|
+
IO.console.erase_screen(Aro::Mancy::S)
|
|
435
|
+
height, width = IO.console.winsize
|
|
436
|
+
IO.console.goto(height, Aro::Mancy::O)
|
|
437
|
+
process_cmd(cmd)
|
|
438
|
+
end
|
|
235
439
|
|
|
236
|
-
|
|
237
|
-
$stdout = StringIO.open do |out|
|
|
238
|
-
cmd = nil
|
|
239
|
-
loop do
|
|
240
|
-
# erase before cursor
|
|
241
|
-
process_cmd(cmd)
|
|
242
|
-
IO.console.goto(Aro::Config.display_configuration[:HEIGHT], Aro::Mancy::O)
|
|
243
|
-
break unless @running && cmd = Readline.readline(calc_ps1, true)
|
|
244
|
-
IO.console.erase_screen(Aro::Mancy::S)
|
|
440
|
+
out
|
|
245
441
|
end
|
|
246
442
|
|
|
247
|
-
|
|
443
|
+
CLI::EXIT_CODES[:SUCCESS]
|
|
444
|
+
ensure
|
|
445
|
+
$stdout = original_stdout
|
|
248
446
|
end
|
|
249
|
-
|
|
250
|
-
CLI::EXIT_CODES[:SUCCESS]
|
|
251
|
-
ensure
|
|
252
|
-
$stdout = original_stdout
|
|
253
447
|
end
|
|
254
448
|
|
|
255
449
|
def main(cmd)
|
|
@@ -257,154 +451,205 @@ module Aos
|
|
|
257
451
|
return false if cmd.nil?
|
|
258
452
|
|
|
259
453
|
# get args
|
|
260
|
-
args =
|
|
454
|
+
args = cmd.split(" ")
|
|
261
455
|
return false if args[0].nil?
|
|
262
456
|
return false if args[0] == :aos.to_s
|
|
263
457
|
|
|
264
|
-
|
|
458
|
+
# if self.you.home? && self.you.user?
|
|
459
|
+
# configure_readline :home
|
|
460
|
+
# self.display_lines = [`#{cmd}`]
|
|
461
|
+
# # render
|
|
462
|
+
|
|
463
|
+
# return false
|
|
464
|
+
# end
|
|
465
|
+
|
|
466
|
+
# send to "system" call in process_cmd method
|
|
467
|
+
# if args[Aro::Mancy::O] is not in Aos::Os::CMDS
|
|
468
|
+
send_to_system_call = !Aos::Os.is_aos_command?(args[Aro::Mancy::O])
|
|
265
469
|
|
|
266
|
-
|
|
267
|
-
|
|
470
|
+
# the command is valid
|
|
471
|
+
unless send_to_system_call
|
|
268
472
|
|
|
269
|
-
|
|
270
|
-
unless passthrough
|
|
271
|
-
Dir.chdir(@you.pwd) do
|
|
473
|
+
Dir.chdir(self.you.pwd) do
|
|
272
474
|
# process commands
|
|
273
475
|
case args[Aro::Mancy::O].to_sym
|
|
476
|
+
when Aos::Os::CMDS[:ABOT][:key]
|
|
477
|
+
# abot
|
|
478
|
+
send_to_system_call = Aos::Abot.process_cmd(args)
|
|
274
479
|
when Aos::Os::CMDS[:AMG][:key]
|
|
275
|
-
#
|
|
276
|
-
|
|
277
|
-
when Aos::Os::CMDS[:
|
|
480
|
+
# amg
|
|
481
|
+
send_to_system_call = Aos::Amg.process_cmd(args)
|
|
482
|
+
when Aos::Os::CMDS[:CD][:key]
|
|
483
|
+
# cd
|
|
484
|
+
handle_cd(args)
|
|
485
|
+
when Aos::Os::CMDS[:COR][:key]
|
|
278
486
|
# config
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
487
|
+
send_to_system_call = true
|
|
488
|
+
Aos::Cor.process_command(args)
|
|
489
|
+
when Aos::Os::CMDS[:DATA][:key]
|
|
490
|
+
# data
|
|
491
|
+
send_to_system_call = Aos::Data.process_cmd(args)
|
|
492
|
+
when Aos::Os::CMDS[:EXIT][:key]
|
|
493
|
+
# exit
|
|
494
|
+
send_to_system_call = true
|
|
495
|
+
handle_exit(args)
|
|
496
|
+
when Aos::Os::CMDS[:FLIE][:key]
|
|
497
|
+
# amg
|
|
498
|
+
send_to_system_call = Aos::Flie.process_cmd(args)
|
|
499
|
+
when Aos::Os::CMDS[:HELP][:key]
|
|
500
|
+
# help
|
|
501
|
+
send_to_system_call = handle_help(args)
|
|
283
502
|
when Aos::Os::CMDS[:LL][:key]
|
|
284
503
|
# ll
|
|
504
|
+
send_to_system_call = false
|
|
285
505
|
handle_ll(args)
|
|
506
|
+
when Aos::Os::CMDS[:LS][:key]
|
|
507
|
+
# ls
|
|
508
|
+
handle_ls(args)
|
|
286
509
|
when Aos::Os::CMDS[:PWD][:key]
|
|
287
510
|
# pwd
|
|
288
511
|
handle_pwd(args)
|
|
289
|
-
when Aos::Os::CMDS[:EXIT][:key]
|
|
290
|
-
# exit
|
|
291
|
-
passthrough = true
|
|
292
|
-
handle_exit(args)
|
|
293
|
-
when Aos::Os::CMDS[:HELP][:key]
|
|
294
|
-
# help
|
|
295
|
-
passthrough = handle_help(args)
|
|
296
|
-
when Aos::Os::CMDS[:CD][:key]
|
|
297
|
-
# cd
|
|
298
|
-
handle_cd(args)
|
|
299
512
|
end
|
|
300
513
|
end
|
|
301
514
|
end
|
|
302
515
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
516
|
+
if send_to_system_call
|
|
517
|
+
# process ilib commands
|
|
518
|
+
ilib = Aos::Ilib.find_by(
|
|
519
|
+
name: args[Aro::Mancy::O],
|
|
520
|
+
status: :installed
|
|
521
|
+
)
|
|
522
|
+
unless ilib.nil?
|
|
523
|
+
self.display_lines = [ilib.usage]
|
|
524
|
+
send_to_system_call = false
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
# if system is going to run, but redirect happens,
|
|
528
|
+
# cancel system run.
|
|
529
|
+
if redirect_to_room(args[Aro::Mancy::O])
|
|
530
|
+
send_to_system_call = false
|
|
531
|
+
end
|
|
308
532
|
end
|
|
309
533
|
|
|
310
|
-
return
|
|
534
|
+
return send_to_system_call
|
|
311
535
|
end
|
|
312
536
|
|
|
313
537
|
def calc_ps1
|
|
314
|
-
|
|
315
|
-
"#{Aos::Os::PS1}"
|
|
316
|
-
end
|
|
317
|
-
|
|
318
|
-
def handle_aro_override(args)
|
|
319
|
-
if args[0].include?(:aro.to_s)
|
|
320
|
-
args = "#{args.join(" ")} #{:aos.to_s}".split(" ")
|
|
321
|
-
end
|
|
322
|
-
args
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
def handle_config(args)
|
|
326
|
-
Aro::Config.process_config_command(args)
|
|
327
|
-
return true
|
|
538
|
+
self.you_flag.nil? ? Aos::Os::PS1.to_s : ">[#{self.you_flag.name}]>: "
|
|
328
539
|
end
|
|
329
540
|
|
|
330
541
|
def redirect_to_room(arg)
|
|
331
542
|
# search for reserved room path
|
|
332
543
|
handled = false
|
|
333
|
-
|
|
334
|
-
if !room_path.empty?
|
|
544
|
+
if arg.to_sym == Aro::Dom::COR
|
|
335
545
|
handled = true
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
546
|
+
self.you.home!
|
|
547
|
+
else
|
|
548
|
+
room_path = Aro::Dom.room_path(arg)
|
|
549
|
+
if !self.you.root? &&
|
|
550
|
+
room_path.include?(Aro::Dom::ROOT.to_s)
|
|
551
|
+
self.display_lines = ["invalid access to #{room_path}. doing nothing."]
|
|
552
|
+
elsif !room_path.empty?
|
|
553
|
+
handled = true
|
|
554
|
+
if room_path == Aro::Dom::HOME.to_s
|
|
555
|
+
self.you.home!
|
|
556
|
+
else
|
|
557
|
+
Aro::D.say("#{__method__}#{Aos::Os::A}#{room_path}")
|
|
558
|
+
self.you.update(pwd: File.join(
|
|
559
|
+
Aro::Dom.dom_root,
|
|
560
|
+
room_path
|
|
561
|
+
))
|
|
562
|
+
end
|
|
563
|
+
end
|
|
340
564
|
end
|
|
341
565
|
handled
|
|
342
566
|
end
|
|
343
567
|
|
|
344
|
-
def handle_amg(args)
|
|
345
|
-
Aos::Amg.process_cmd(args)
|
|
346
|
-
end
|
|
347
|
-
|
|
348
568
|
def handle_help(args)
|
|
349
569
|
redirect_to_room(Aro::Dom::WAITE)
|
|
350
570
|
return false
|
|
351
571
|
end
|
|
352
572
|
|
|
353
573
|
def handle_ls(args)
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
574
|
+
args = Aos::Os.sanitize_you(args)
|
|
575
|
+
self.display_lines = [get_ls(args)]
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
def get_ls(args, split = false)
|
|
579
|
+
"\n" + Dir.glob(
|
|
580
|
+
File.join(
|
|
581
|
+
self.you.pwd,
|
|
582
|
+
(args[1] || "") + Aos::Os::STAR.to_s
|
|
583
|
+
),
|
|
584
|
+
File::FNM_EXTGLOB
|
|
585
|
+
).map{|p|
|
|
586
|
+
">/" + Aos::Os::osify(p)
|
|
587
|
+
}.join("\n")
|
|
357
588
|
end
|
|
358
589
|
|
|
359
590
|
def handle_ll(args)
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
]
|
|
591
|
+
args = Aos::Os.sanitize_you(args)
|
|
592
|
+
self.display_lines = [Dir.glob(File.join(self.you.pwd, (args[1] || "") + Aos::Os::STAR.to_s), File::FNM_DOTMATCH).map{|p| Aos::Os::osify(p.strip, true)}.join("\n")]
|
|
363
593
|
end
|
|
364
594
|
|
|
365
595
|
def handle_pwd(args)
|
|
366
|
-
osified = "/" + Aos::Os::osify(
|
|
596
|
+
osified = "/" + Aos::Os::osify(self.you.pwd)
|
|
367
597
|
self.display_lines = [osified]
|
|
368
598
|
end
|
|
369
599
|
|
|
370
600
|
def handle_exit(args)
|
|
371
|
-
Aos::
|
|
372
|
-
|
|
601
|
+
Aos::Os.say(["#{Aos::Os} is exiting..."])
|
|
602
|
+
begin
|
|
603
|
+
Aos::Abot.terminate
|
|
604
|
+
Aos::Os.terminateq
|
|
605
|
+
rescue StandardError => e
|
|
606
|
+
Aro::D.say(e)
|
|
607
|
+
end
|
|
608
|
+
self.running = false
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
def handle_new_pwd(new_pwd)
|
|
612
|
+
if !you.root? &&
|
|
613
|
+
new_pwd.include?(Aro::Dom::ROOT.to_s)
|
|
614
|
+
self.display_lines = ["invalid access to #{Aos::Os.osify(new_pwd)}. doing nothing."]
|
|
615
|
+
elsif Aos::Os.osify(new_pwd) == Aro::Dom::HOME.to_s
|
|
616
|
+
self.you.home!
|
|
617
|
+
else
|
|
618
|
+
Aro::V.say("new_pwd: #{new_pwd}")
|
|
619
|
+
self.you.update(pwd: new_pwd)
|
|
620
|
+
end
|
|
373
621
|
end
|
|
374
622
|
|
|
375
623
|
def handle_cd(args)
|
|
624
|
+
args = Aos::Os.sanitize_you(args)
|
|
376
625
|
if args[1].nil? || args[1] == "~/"
|
|
377
626
|
# no arg takes you to arodom root
|
|
378
|
-
|
|
627
|
+
self.you.update(pwd: File.dirname(Aro::Dom.ethergeist_path))
|
|
379
628
|
else
|
|
380
629
|
if args[1].include?(Aro::Dom::DOTT.to_s)
|
|
381
630
|
# going up
|
|
382
|
-
if File.dirname(Aro::Dom.ethergeist_path) ==
|
|
631
|
+
if File.dirname(Aro::Dom.ethergeist_path) == self.you.pwd
|
|
383
632
|
self.display_lines = ["within #{Aos::Os}, one cannot leave the #{Aro::Dom}."]
|
|
384
633
|
else
|
|
385
634
|
# todo: support dots in paths
|
|
386
635
|
# this only supports moving one level up
|
|
387
636
|
|
|
388
|
-
pwd_arr =
|
|
637
|
+
pwd_arr = self.you.pwd.split("/")
|
|
389
638
|
new_pwd = (pwd_arr.first(pwd_arr.length - 1)).join("/")
|
|
390
639
|
|
|
391
|
-
|
|
640
|
+
handle_new_pwd(new_pwd)
|
|
392
641
|
end
|
|
393
642
|
else
|
|
394
643
|
# this particular block needs to be better
|
|
395
644
|
if args[1][0] == "/"
|
|
396
|
-
Aro::V.say("handling cd to root (/) arg...")
|
|
397
|
-
Aro::V.say(Aro::Dom::dom_root)
|
|
398
|
-
Aro::V.say(args[1][1..])
|
|
399
645
|
args[1] = args[1][1..]
|
|
400
646
|
new_pwd = File.join(Aro::Dom.dom_root, args[1])
|
|
401
647
|
if Dir.exist?(new_pwd)
|
|
402
|
-
|
|
648
|
+
handle_new_pwd(new_pwd)
|
|
403
649
|
end
|
|
404
650
|
elsif Dir.exist?(args[1]) && args[1] != Aro::Dom::DOT.to_s
|
|
405
|
-
new_pwd = File.join(
|
|
406
|
-
|
|
407
|
-
@you.update(pwd: new_pwd)
|
|
651
|
+
new_pwd = File.join(self.you.pwd, args[1])
|
|
652
|
+
handle_new_pwd(new_pwd)
|
|
408
653
|
else
|
|
409
654
|
self.display_lines = ["that directory is invalid."]
|
|
410
655
|
end
|