Module: BuiltinCommands
- Included in:
- CommandCenter, Kernel
- Defined in:
- lib/rust/commands/builtins.rb,
lib/rust/commands/builtins/cd.rb,
lib/rust/commands/commands/ls.rb,
lib/rust/commands/commands/rm.rb,
lib/rust/commands/builtins/pwd.rb,
lib/rust/commands/builtins/exit.rb,
lib/rust/commands/builtins/help.rb,
lib/rust/commands/builtins/type.rb,
lib/rust/commands/commands/read.rb,
lib/rust/commands/commands/test.rb,
lib/rust/commands/builtins/parser.rb
Overview
Created by me on 2011-12-26.
Copyright (c) 2011. All pwnage reserved.
Class Method Summary collapse
Instance Method Summary collapse
- #cd(*args) ⇒ Object
- #exit(*args) ⇒ Object
- #help(*args) ⇒ Object
- #ls(*args) ⇒ Object
- #parser(*args) ⇒ Object
- #pwd(*args) ⇒ Object
- #read(*args) ⇒ Object
- #rm(*args) ⇒ Object
- #test(*args) ⇒ Object
- #type(*args) ⇒ Object
Class Method Details
.builtins ⇒ Object
18 19 20 |
# File 'lib/rust/commands/builtins.rb', line 18 def builtins @@builtins end |
.commands ⇒ Object
22 23 24 |
# File 'lib/rust/commands/builtins.rb', line 22 def commands @@commands end |
.register(cmd) ⇒ Object
8 9 10 11 |
# File 'lib/rust/commands/builtins.rb', line 8 def register cmd @@commands ||= [] @@commands << cmd end |
.register_builtin(cmd) ⇒ Object
13 14 15 16 |
# File 'lib/rust/commands/builtins.rb', line 13 def register_builtin cmd @@builtins ||= [] @@builtins << cmd end |
Instance Method Details
#cd(*args) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/rust/commands/builtins/cd.rb', line 7 def cd *args (err "Too Many Arguments - Try only one"; return) if args.size > 1 directory = args[0] ? args[0] : ENV['HOME'] (directory = File.join(Dir.pwd, directory)) unless directory[0].chr =~ /\// Dir.chdir directory puts("Changing to #{directory}") end |
#exit(*args) ⇒ Object
8 9 10 |
# File 'lib/rust/commands/builtins/exit.rb', line 8 def exit *args Kernel.exit end |
#help(*args) ⇒ Object
8 9 10 11 |
# File 'lib/rust/commands/builtins/help.rb', line 8 def help *args puts "INTERNAL COMMANDS" puts(builtins.join(', ')) end |
#ls(*args) ⇒ Object
8 9 10 |
# File 'lib/rust/commands/commands/ls.rb', line 8 def ls *args puts(Dir['*']) end |
#parser(*args) ⇒ Object
8 9 10 |
# File 'lib/rust/commands/builtins/parser.rb', line 8 def parser *args puts($parser) end |
#pwd(*args) ⇒ Object
8 9 10 |
# File 'lib/rust/commands/builtins/pwd.rb', line 8 def pwd *args puts(Dir.pwd) end |
#read(*args) ⇒ Object
8 9 10 |
# File 'lib/rust/commands/commands/read.rb', line 8 def read *args puts(open(args[0], "r").read) end |
#rm(*args) ⇒ Object
9 10 11 |
# File 'lib/rust/commands/commands/rm.rb', line 9 def rm *args puts('rm') end |
#test(*args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rust/commands/commands/test.rb', line 8 def test *args opts = Trollop::(args) do opt :verbose, "Be as loud as possible" opt :out, "Where to save the file", :type => String opt :threads, "Set number of threads to use", :default => 5 end opts[:in] = args[0] p opts end |
#type(*args) ⇒ Object
8 9 10 |
# File 'lib/rust/commands/builtins/type.rb', line 8 def type *args puts("type") end |