Class: CDWish

Inherits:
Djinni::Wish
  • Object
show all
Defined in:
lib/jenkins_shell/wish/cd_wish.rb

Instance Method Summary collapse

Instance Method Details

#aliasesObject



5
6
7
# File 'lib/jenkins_shell/wish/cd_wish.rb', line 5

def aliases
    return ["cd"]
end

#descriptionObject



9
10
11
# File 'lib/jenkins_shell/wish/cd_wish.rb', line 9

def description
    return "Change to new directory"
end

#execute(args, djinni_env = Hash.new) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jenkins_shell/wish/cd_wish.rb', line 13

def execute(args, djinni_env = Hash.new)
    case djinni_env["os"]
    when JenkinsShell::OS.LINUX
        puts "Currently unsupported for Linux"
        return
    end

    usage if (args.empty?)

    jsh = djinni_env["jsh"]
    if (!jsh.cd(args))
        puts "Directory not found"
        return
    end

    case djinni_env["os"]
    when JenkinsShell::OS.LINUX
        djinni_env["djinni_prompt"] = "#{jsh.cwd}$ ".light_white
    when JenkinsShell::OS.WINDOWS
        djinni_env["djinni_prompt"] = "#{jsh.cwd}> ".light_white
    end
end

#usageObject



36
37
38
39
# File 'lib/jenkins_shell/wish/cd_wish.rb', line 36

def usage
    puts "#{aliases.join(", ")} <directory>"
    puts "    #{description}."
end