Class: Elasticshell::Commands::Cd
Instance Attribute Summary
#input, #shell
Class Method Summary
collapse
Instance Method Summary
collapse
#be_connected!, #initialize
Class Method Details
.matches?(input) ⇒ Boolean
5
6
7
|
# File 'lib/elasticshell/commands/cd.rb', line 5
def self.matches? input
input =~ /^cd/
end
|
Instance Method Details
#evaluate! ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/elasticshell/commands/cd.rb', line 9
def evaluate!
if input =~ /^cd$/
shell.scope = Scopes.global(:client => shell.client)
return
end
return unless input =~ /^cd\s+(.+)$/
scope = $1
if scope =~ %r!^/!
shell.scope = Scopes.from_path(scope, :client => shell.client)
else
shell.scope = Scopes.from_path(File.expand_path(File.join(shell.scope.path, scope)), :client => shell.client)
end
end
|