Class: Jank::JankCommand
Instance Method Summary
collapse
Methods inherited from Command
#dispatch, #initialize
Constructor Details
This class inherits a constructor from Jank::Command
Instance Method Details
#config_command ⇒ Object
5
6
7
|
# File 'lib/jank_command.rb', line 5
def config_command
puts @config.to_yaml
end
|
#config_help_text ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/jank_command.rb', line 93
def config_help_text
<<-HELPTEXT
usage: jank config
Displays the jank configuration for the current directory.
HELPTEXT
end
|
#gopath_command ⇒ Object
18
19
20
|
# File 'lib/jank_command.rb', line 18
def gopath_command
puts @config.env['GOPATH']
end
|
#gopath_help_text ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/jank_command.rb', line 101
def gopath_help_text
<<-HELPTEXT
usage: jank path
Displays additional gopaths for this directory. Paths can
be added by placing .jank files in directories with the
key 'gopath'. The gopath key can map to a string or an array
of additional gopaths. Gopaths are scanned for in this manner
up the filesystem until the user's home directory.
Gopaths specified in the .jank file can be either absolute
paths or paths relative to the directory.
HELPTEXT
end
|
#help ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/jank_command.rb', line 9
def help
topic_help = "#{@args[1]}_help_text"
if self.respond_to? topic_help
puts self.send(topic_help)
else
puts jank_help_text
end
end
|
#jank_help_text ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/jank_command.rb', line 70
def jank_help_text
<<-HELPTEXT
Jank - the janky gopath tool.
Usage:
jank command [arguments]
The commands are:
config show the jank configuration for the directory
gopath displays gopath for the directory
help show this!
link link a go-gettable source tree into the gopath
package displays the package for the current directory
stat lists packages linked into gopath
sync syncs packages linked into gopath
unlink unlink a go-gettable source tree from the gopath
Use "jank help [command]" for more information about a command.
HELPTEXT
end
|
#link_command ⇒ Object
22
23
24
|
# File 'lib/jank_command.rb', line 22
def link_command
puts "Package #{@config.package || '[UNKNOWN]'} is not jankable" if !@janker.link
end
|
#link_help_text ⇒ Object
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/jank_command.rb', line 116
def link_help_text
<<-HELPTEXT
usage: jank link
For packages developed in a go-gettable stlye outside the
gopath, invoking link will link the package into the gopath.
This requires that the directory or some parent contains a
.jank file with the 'package' key set to go package name.
HELPTEXT
end
|
#package_command ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/jank_command.rb', line 26
def package_command
if ARGV[1] == '-r' || ARGV[1] == '--reverse'
package = ARGV[2]
if package == nil
STDERR.puts puts package_help_text
exit(1)
end
@janker.sync_packages
puts @janker.location_of_package(package)
exit
end
path = ARGV[1]
if path == nil
puts @config.package
exit
end
@janker.sync_packages
puts @janker.package_for_location path
end
|
#package_help_text ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/jank_command.rb', line 127
def package_help_text
<<-HELPTEXT
usage: jank package [flags] [path]
Flags:
-r, --reverse
Return directory for go package
Displays the package for the current directory or the path
if specified. Specifiying the reverse flag returns the
filesystem path of a go package.
HELPTEXT
end
|
#stat_command ⇒ Object
49
50
51
52
53
54
|
# File 'lib/jank_command.rb', line 49
def stat_command
@janker.sync_packages
@janker.walk_janked_packages do |package, local_path, go_path|
puts "#{package} --> #{local_path}"
end
end
|
#stat_help_text ⇒ Object
141
142
143
144
145
146
147
148
|
# File 'lib/jank_command.rb', line 141
def stat_help_text
<<-HELPTEXT
usage: jank stat
Displays a mapping of packages in the gopath that are linked
to go-gettable source trees that reside outside of the gopath.
HELPTEXT
end
|
#sync_command ⇒ Object
56
57
58
|
# File 'lib/jank_command.rb', line 56
def sync_command
@janker.sync_packages
end
|
#sync_help_text ⇒ Object
150
151
152
153
154
155
156
|
# File 'lib/jank_command.rb', line 150
def sync_help_text
<<-HELPTEXT
usage: jank sync
Syncs all packages linked into the gopath.
HELPTEXT
end
|
#unlink_command ⇒ Object
60
61
62
63
64
65
66
67
68
|
# File 'lib/jank_command.rb', line 60
def unlink_command
all = @args[1] == '-a' || @args[1] == '--all'
if all
@janker.unlink_all
else
puts "Package #{@config.package || '[UNKNOWN]'} is not jankable" if !@janker.unlink
end
end
|
#unlink_help_text ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/jank_command.rb', line 158
def unlink_help_text
<<-HELPTEXT
usage: jank unlink [flags]
Flags:
-a, --all
Unlink all linked packages
For packages developed in a go-gettable stlye outside the
gopath, invoking unlink will remove the package from the
gopath. This requires that the directory or some parent
contains a .jank file with the 'package' key set to go
package name.
HELPTEXT
end
|