aro 0.2.4 → 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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/Gemfile.lock +126 -50
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/aro.gemspec +10 -11
  7. data/bin/oss_om +15 -0
  8. data/checksums/aro-0.2.4.gem.sha512 +1 -0
  9. data/checksums/aro-0.2.5.gem.sha512 +1 -0
  10. data/checksums/aro-0.2.6.gem.sha512 +1 -0
  11. data/locale/en.cards.yml +19 -21
  12. data/locale/en.cmd.yml +34 -0
  13. data/locale/en.cor.yml +5 -8
  14. data/locale/en.menu_items.yml +2 -0
  15. data/locale/en.menus.yml +2 -0
  16. data/locale/en.usage.yml +24 -45
  17. data/locale/en.yml +61 -49
  18. data/sys/aro/cmd.rb +96 -0
  19. data/sys/{aos → aro}/cor.rb +224 -268
  20. data/sys/aro/d.rb +4 -3
  21. data/sys/aro/db/migrate/.DS_Store +0 -0
  22. data/sys/aro/db/migrate/1793913747_create_data_bases.rb +13 -0
  23. data/sys/aro/db/migrate/1793913777_create_data_base_directories.rb +14 -0
  24. data/sys/aro/db/migrate/1793913796_create_data_base_files.rb +12 -0
  25. data/sys/aro/db/migrate/1793913841_create_menus.rb +11 -0
  26. data/sys/aro/db/migrate/1793913861_create_menu_items.rb +14 -0
  27. data/sys/aro/db.rb +72 -33
  28. data/sys/aro/designer.rb +281 -0
  29. data/sys/aro/locale.rb +136 -0
  30. data/sys/aro/ma_ain.rb +54 -0
  31. data/sys/aro/mancy.rb +53 -28
  32. data/sys/aro/models/concerns/.keep +0 -0
  33. data/sys/aro/models/concerns/uuid.rb +29 -0
  34. data/sys/aro/models/data_base.rb +97 -0
  35. data/sys/aro/models/directory.rb +44 -0
  36. data/sys/aro/models/file.rb +27 -0
  37. data/sys/aro/models/menu.rb +27 -0
  38. data/sys/aro/models/menu_item.rb +47 -0
  39. data/sys/aro/models/teck.rb +40 -31
  40. data/sys/aro/p.rb +6 -3
  41. data/sys/aro/r.rb +1 -2
  42. data/sys/aro/store.rb +147 -0
  43. data/sys/aro/v.rb +2 -2
  44. data/sys/aro/views/base.rb +25 -0
  45. data/sys/aro/views/teck.rb +30 -0
  46. data/sys/aro.rb +1 -2
  47. data/sys/cli/constants.rb +1 -7
  48. data/sys/cli/create.rb +3 -3
  49. data/sys/cli/nterface.rb +8 -8
  50. data/sys/cli/teck.rb +17 -18
  51. data/sys/cli/usage.rb +4 -4
  52. data/sys/cli.rb +0 -1
  53. data/sys/reiquire.rb +146 -25
  54. data/sys/shr/.DS_Store +0 -0
  55. data/sys/shr/prompt.rb +8 -2
  56. data/sys/shr/t.rb +5 -5
  57. data/sys/shr/version.rb +9 -2
  58. data/tasks/make.rake +2 -1
  59. metadata +57 -103
  60. data/bin/aos +0 -31
  61. data/bin/aro +0 -60
  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 -46
  67. data/locale/en.flie.yml +0 -29
  68. data/sys/aos/abot.rb +0 -255
  69. data/sys/aos/amg.rb +0 -184
  70. data/sys/aos/aos.rb +0 -665
  71. data/sys/aos/data.rb +0 -117
  72. data/sys/aos/db/migrate/1765148774_create_yous.rb +0 -20
  73. data/sys/aos/db/migrate/1765762724_create_ilibs.rb +0 -22
  74. data/sys/aos/db/migrate/1765907766_create_ilogs.rb +0 -18
  75. data/sys/aos/db/migrate/1765933985_create_agodos.rb +0 -22
  76. data/sys/aos/db/migrate/1766203888_create_fpxies.rb +0 -18
  77. data/sys/aos/db.rb +0 -105
  78. data/sys/aos/flie.rb +0 -144
  79. data/sys/aos/models/agodo.rb +0 -95
  80. data/sys/aos/models/fpxy.rb +0 -26
  81. data/sys/aos/models/ilib.rb +0 -46
  82. data/sys/aos/models/ilog.rb +0 -27
  83. data/sys/aos/models/you.rb +0 -102
  84. data/sys/aos/s.rb +0 -26
  85. data/sys/aos/vws/base.rb +0 -159
  86. data/sys/aos/vws/dom.rb +0 -32
  87. data/sys/aos/vws/games/abot.rb +0 -21
  88. data/sys/aos/vws/games/teck.rb +0 -124
  89. data/sys/aos/vws/games.rb +0 -19
  90. data/sys/aos/vws/home.rb +0 -23
  91. data/sys/aos/vws/know/body.rb +0 -19
  92. data/sys/aos/vws/know/mind.rb +0 -19
  93. data/sys/aos/vws/know/spirit.rb +0 -19
  94. data/sys/aos/vws/know.rb +0 -19
  95. data/sys/aos/vws/root/amg.rb +0 -21
  96. data/sys/aos/vws/root/config.rb +0 -21
  97. data/sys/aos/vws/root/data.rb +0 -21
  98. data/sys/aos/vws/root/flie.rb +0 -21
  99. data/sys/aos/vws/root.rb +0 -19
  100. data/sys/aos/vws/welcome/waite.rb +0 -31
  101. data/sys/aos/vws/welcome/winner.rb +0 -19
  102. data/sys/aos/vws/welcome.rb +0 -66
  103. data/sys/aro/models/base_model.rb +0 -13
  104. data/sys/cli/dom.rb +0 -43
  105. data/sys/dom/d.rb +0 -138
  106. data/sys/dom/dom.rb +0 -210
  107. data/sys/dom/p.rb +0 -17
  108. data/sys/fpx.rb +0 -104
  109. data/sys/shr/ilib/crs/CMakeLists.txt +0 -12
  110. data/sys/shr/ilib/crs/compile.sh +0 -5
  111. data/sys/shr/ilib/crs/crs.c +0 -24
  112. data/sys/shr/ilib/crs/crs.o +0 -0
  113. data/sys/shr/ilib/crs/libcrs.so +0 -0
data/sys/aos/aos.rb DELETED
@@ -1,665 +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
- end
200
- end
201
-
202
- def load_you
203
- return unless self.you_flag.nil?
204
- load_you!
205
- end
206
-
207
- def get_pwd_for(you_name)
208
- Aos::You.find_by(name: you_name)&.pwd
209
- end
210
-
211
- def load_view
212
- view_name = Aos::Os.osify(self.you.pwd).split("/").last || :dom.to_s
213
- view_cls = nil
214
-
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
230
- end
231
- end
232
-
233
- Aro::D.say("loading view #{view_cls}")
234
- @view = view_cls
235
- end
236
-
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? && !Aos::Os.osify(self.you.pwd).include?(Aro::Dom.room_path(:abot))
244
- if Aro::Mancy.is_initialized? && !Aro::Mancy.teck.nil?
245
- Aro::Mancy.init
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"))
270
- else
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
288
- end
289
- end
290
- end
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
-
374
- Mutex.new.synchronize do
375
- def process_cmd(cmd)
376
- Aos::Cor.instance.cor_path = nil
377
- Aos::Cor.instance.load
378
- Dir.chdir(self.you.reload.pwd) do
379
- send_to_system_call = main(cmd)
380
- nothing = nil
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}`
387
- end
388
-
389
- unless nothing.nil?
390
- Aos::Os.say(nothing)
391
- else
392
- render
393
- end
394
- end
395
-
396
- CLI::EXIT_CODES[:SUCCESS]
397
- end
398
- end
399
-
400
- def configure_readline(env)
401
- # case env
402
- # when :home
403
- Readline.completion_append_character = "/"
404
- Readline.completion_proc = Proc.new{|str|
405
- pwd = self.you_flag&.reload&.pwd || self.you&.reload&.pwd || ""
406
- dir_matcher = File.join(pwd, str + Aos::Os::STAR.to_s)
407
- # Aro::V.say(dir_matcher)
408
- dir_listing = Dir.glob(dir_matcher, File::FNM_DOTMATCH).map{|d| Aos::Os.osify(d).split("/").reject{|p| pwd.include?(p)}.join("/")}
409
- # Aro::V.say(dir_listing)
410
- dir_listing.grep(/^#{Regexp.escape(str)}/)
411
- }
412
- # when :aos
413
- # Readline.completion_append_character = "/"
414
- # Readline.completion_proc = Proc.new{|str|
415
- # Aro::Dom::D.reserved_words.grep(/^#{Regexp.escape(str)}/)
416
- # }
417
- # end
418
- end
419
-
420
- Mutex.new.synchronize do
421
- def run
422
- # run condition
423
- self.running = true
424
-
425
- # start cron
426
- Aos::Os.cron
427
-
428
- original_stdout = $stdout
429
- $stdout = StringIO.open do |out|
430
- cmd = nil
431
-
432
- loop do
433
- height, width = IO.console.winsize
434
- IO.console.goto(height, Aro::Mancy::O)
435
- process_cmd(cmd)
436
- break unless self.running && cmd = Readline.readline(calc_ps1)
437
- IO.console.erase_screen(Aro::Mancy::S)
438
- configure_readline :aos
439
- end
440
-
441
-
442
- out
443
- end
444
-
445
- CLI::EXIT_CODES[:SUCCESS]
446
- ensure
447
- $stdout = original_stdout
448
- end
449
- end
450
-
451
- def main(cmd)
452
- # begin game loop
453
- return false if cmd.nil?
454
-
455
- # get args
456
- args = cmd.split(" ")
457
- return false if args[0].nil?
458
- return false if args[0] == :aos.to_s
459
-
460
- # if self.you.home? && self.you.user?
461
- # configure_readline :home
462
- # self.display_lines = [`#{cmd}`]
463
- # # render
464
-
465
- # return false
466
- # end
467
-
468
- # send to "system" call in process_cmd method
469
- # if args[Aro::Mancy::O] is not in Aos::Os::CMDS
470
- send_to_system_call = !Aos::Os.is_aos_command?(args[Aro::Mancy::O])
471
-
472
- # the command is valid
473
- unless send_to_system_call
474
-
475
- Dir.chdir(self.you.pwd) do
476
- # process commands
477
- case args[Aro::Mancy::O].to_sym
478
- when Aos::Os::CMDS[:ABOT][:key]
479
- # abot
480
- send_to_system_call = Aos::Abot.process_cmd(args)
481
- when Aos::Os::CMDS[:AMG][:key]
482
- # amg
483
- send_to_system_call = Aos::Amg.process_cmd(args)
484
- when Aos::Os::CMDS[:CD][:key]
485
- # cd
486
- handle_cd(args)
487
- when Aos::Os::CMDS[:COR][:key]
488
- # config
489
- send_to_system_call = true
490
- Aos::Cor.process_command(args)
491
- when Aos::Os::CMDS[:DATA][:key]
492
- # data
493
- send_to_system_call = Aos::Data.process_cmd(args)
494
- when Aos::Os::CMDS[:EXIT][:key]
495
- # exit
496
- send_to_system_call = true
497
- handle_exit(args)
498
- when Aos::Os::CMDS[:FLIE][:key]
499
- # amg
500
- send_to_system_call = Aos::Flie.process_cmd(args)
501
- when Aos::Os::CMDS[:HELP][:key]
502
- # help
503
- send_to_system_call = handle_help(args)
504
- when Aos::Os::CMDS[:LL][:key]
505
- # ll
506
- send_to_system_call = false
507
- handle_ll(args)
508
- when Aos::Os::CMDS[:LS][:key]
509
- # ls
510
- handle_ls(args)
511
- when Aos::Os::CMDS[:PWD][:key]
512
- # pwd
513
- handle_pwd(args)
514
- end
515
- end
516
- end
517
-
518
- if send_to_system_call
519
- # process ilib commands
520
- ilib = Aos::Ilib.find_by(
521
- name: args[Aro::Mancy::O],
522
- status: :installed
523
- )
524
- unless ilib.nil?
525
- self.display_lines = [ilib.usage]
526
- send_to_system_call = false
527
- end
528
-
529
- # if system is going to run, but redirect happens,
530
- # cancel system run.
531
- if redirect_to_room(args[Aro::Mancy::O])
532
- send_to_system_call = false
533
- end
534
- end
535
-
536
- return send_to_system_call
537
- end
538
-
539
- def calc_ps1
540
- self.you_flag.nil? ? Aos::Os::PS1.to_s : ">[#{self.you_flag.name}]>: "
541
- end
542
-
543
- def redirect_to_room(arg)
544
- # search for reserved room path
545
- handled = false
546
- if arg.to_sym == Aro::Dom::COR
547
- handled = true
548
- self.you.home!
549
- else
550
- room_path = Aro::Dom.room_path(arg)
551
- Aro::D.say("#{__method__}#{Aos::Os::A}room_path: #{room_path}")
552
- if !self.you.root? &&
553
- room_path.include?(Aro::Dom::ROOT.to_s)
554
- Aro::D.say("#{__method__}#{Aos::Os::A}invalid")
555
- self.display_lines = ["invalid access to #{room_path}. doing nothing."]
556
- elsif !room_path.empty?
557
- handled = true
558
- if room_path == Aro::Dom::HOME.to_s
559
- Aro::D.say("#{__method__}#{Aos::Os::A}home!")
560
- self.you.home!
561
- else
562
- Aro::D.say("#{__method__}#{Aos::Os::A}#{room_path}")
563
- self.you.update(pwd: File.join(
564
- Aro::Dom.dom_root,
565
- room_path
566
- ))
567
- end
568
- end
569
- end
570
- handled
571
- end
572
-
573
- def handle_help(args)
574
- redirect_to_room(Aro::Dom::WAITE)
575
- return false
576
- end
577
-
578
- def handle_ls(args)
579
- args = Aos::Os.sanitize_you(args)
580
- self.display_lines = [get_ls(args)]
581
- end
582
-
583
- def get_ls(args, split = false)
584
- "\n" + Dir.glob(
585
- File.join(
586
- self.you.pwd,
587
- (args[1] || "") + Aos::Os::STAR.to_s
588
- ),
589
- File::FNM_EXTGLOB
590
- ).map{|p|
591
- ">/" + Aos::Os::osify(p)
592
- }.join("\n")
593
- end
594
-
595
- def handle_ll(args)
596
- args = Aos::Os.sanitize_you(args)
597
- 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")]
598
- end
599
-
600
- def handle_pwd(args)
601
- osified = "/" + Aos::Os::osify(self.you.pwd)
602
- self.display_lines = [osified]
603
- end
604
-
605
- def handle_exit(args)
606
- Aos::Os.say(["#{Aos::Os} is exiting..."])
607
- begin
608
- Aos::Abot.terminate
609
- # Aos::Os.terminateq
610
- rescue StandardError => e
611
- Aro::D.say(e)
612
- end
613
- self.running = false
614
- end
615
-
616
- def handle_new_pwd(new_pwd)
617
- if !you.root? &&
618
- new_pwd.include?(Aro::Dom::ROOT.to_s)
619
- self.display_lines = ["invalid access to #{Aos::Os.osify(new_pwd)}. doing nothing."]
620
- elsif Aos::Os.osify(new_pwd) == Aro::Dom::HOME.to_s
621
- self.you.home!
622
- else
623
- Aro::V.say("new_pwd: #{new_pwd}")
624
- self.you.update(pwd: new_pwd)
625
- end
626
- end
627
-
628
- def handle_cd(args)
629
- args = Aos::Os.sanitize_you(args)
630
- if args[1].nil? || args[1] == "~/"
631
- # no arg takes you to arodom root
632
- self.you.update(pwd: File.dirname(Aro::Dom.ethergeist_path))
633
- else
634
- if args[1].include?(Aro::Dom::DOTT.to_s)
635
- # going up
636
- if File.dirname(Aro::Dom.ethergeist_path) == self.you.pwd
637
- self.display_lines = ["within #{Aos::Os}, one cannot leave the #{Aro::Dom}."]
638
- else
639
- # todo: support dots in paths
640
- # this only supports moving one level up
641
-
642
- pwd_arr = self.you.pwd.split("/")
643
- new_pwd = (pwd_arr.first(pwd_arr.length - 1)).join("/")
644
-
645
- handle_new_pwd(new_pwd)
646
- end
647
- else
648
- # this particular block needs to be better
649
- if args[1][0] == "/"
650
- args[1] = args[1][1..]
651
- new_pwd = File.join(Aro::Dom.dom_root, args[1])
652
- if Dir.exist?(new_pwd)
653
- handle_new_pwd(new_pwd)
654
- end
655
- elsif Dir.exist?(args[1]) && args[1] != Aro::Dom::DOT.to_s
656
- new_pwd = File.join(self.you.pwd, args[1])
657
- handle_new_pwd(new_pwd)
658
- else
659
- self.display_lines = ["that directory is invalid."]
660
- end
661
- end
662
- end
663
- end
664
- end
665
- end