Class: TreeRepl::Use
Instance Attribute Summary
Attributes inherited from Cmd
Instance Method Summary collapse
- #exec(args) ⇒ Object
- #help ⇒ Object
-
#initialize(repl) ⇒ Use
constructor
A new instance of Use.
Constructor Details
#initialize(repl) ⇒ Use
Returns a new instance of Use.
108 109 110 |
# File 'lib/treerepl/cmds.rb', line 108 def initialize(repl) super(repl,'use') end |
Instance Method Details
#exec(args) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/treerepl/cmds.rb', line 114 def exec(args) if args.empty? STDERR.puts 'Missing required argument' return end username = args[0] user = nil begin user = repl.finder.call username rescue Exception => e STDERR.puts "Could not create user for name: #{username}" STDERR.puts e end if user repl.use repl.root_class.new user end end |
#help ⇒ Object
111 112 113 |
# File 'lib/treerepl/cmds.rb', line 111 def help 'Start exploring a certain user' end |