aro 0.2.5 → 0.2.6

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