In Files
Parent
- Object
Information
Command-line Interface
Public Class Methods
main(*argv)
click to toggle source
Initialize and execute command.
# File lib/roll/command.rb, line 16
16: def self.main(*argv)
17: new(*argv).execute
18: end
new(*argv)
click to toggle source
New Command.
# File lib/roll/command.rb, line 21
21: def initialize(*argv)
22: @argv = argv
23: end
Public Instance Methods
env(args, opts)
click to toggle source
Show/Change current environment.
# File lib/roll/command.rb, line 119
119: def env(args, opts)
120: puts Roll.env(*args)
121: end
env_optparse(op, options)
click to toggle source
# File lib/roll/command.rb, line 66
66: def env_optparse(op, options)
67: op.banner = "Usage: roll env [NAME]"
68: op.separator "Show current environment."
69: op
70: end
execute()
click to toggle source
# File lib/roll/command.rb, line 26
26: def execute
27: cmd = @argv.find{ |e| e !~ /^\-/ }
28:
29: options = {}
30:
31: parser = OptionParser.new
32:
33: parser.banner = "Usage: roll [COMMAND]"
34:
35: __send__("#{cmd}_optparse", parser, options) if cmd
36:
37: if !cmd
38: parser.separator "Commands:"
39: parser.separator " in [DIR] " + (" " * 23) + "Roll directory into current environment."
40: parser.separator " out [DIR] " + (" " * 23) + "Remove directory from current environment."
41: parser.separator " env " + (" " * 23) + "Show current environment."
42: parser.separator " index " + (" " * 23) + "Show current environment index."
43: parser.separator " sync " + (" " * 23) + "Synchronize environment indexes."
44: parser.separator " path " + (" " * 23) + "Output bin PATH list."
45: parser.separator " verify " + (" " * 23) + "Verify project dependencies in current environment."
46: parser.separator "Options:"
47: end
48:
49: parser.on_tail("--help", "-h", "Display this help message.") do
50: puts parser
51: exit
52: end
53:
54: parser.parse!
55:
56: ARGV.shift # remove command
57:
58: if cmd
59: __send__(cmd, ARGV, options)
60: else
61: # no command ?
62: end
63: end
in(args, opts)
click to toggle source
# File lib/roll/command.rb, line 145
145: def in(args, opts)
146: path = File.expand_path(args.first || Dir.pwd)
147: depth = opts[:depth]
148: path, file = *Roll.in(path, depth)
149: puts "#{path}"
150: puts " '-> #{file}"
151: end
in_optparse(op, options)
click to toggle source
# File lib/roll/command.rb, line 87
87: def in_optparse(op, options)
88: op.banner = "Usage: roll in [PATH]"
89: op.separator "Insert path into current environment."
90: op.separator "Options:"
91: op.on("--depth", "-d [INTEGER]") do |int|
92: options[:depth] = int
93: end
94: end
index(args, opts)
click to toggle source
Show/Change current environment.
# File lib/roll/command.rb, line 125
125: def index(args, opts)
126: puts Roll.index(*args)
127: end
index_optparse(op, options)
click to toggle source
# File lib/roll/command.rb, line 73
73: def index_optparse(op, options)
74: op.banner = "Usage: roll index [NAME]"
75: op.separator "Show current environment index."
76: op
77: end
out(args, opts)
click to toggle source
# File lib/roll/command.rb, line 154
154: def out(args, opts)
155: path = File.expand_path(args.first || Dir.pwd)
156: path, file = *Roll.out(path)
157: puts "#{file}"
158: puts " '-> #{path} -> [x]"
159: end
out_optparse(op, options)
click to toggle source
# File lib/roll/command.rb, line 97
97: def out_optparse(op, options)
98: op.banner = "Usage: roll out [PATH]"
99: op.separator "Remove path from current environment."
100: op
101: end
path(args, opts)
click to toggle source
This script builds a list of all roll-ready bin locations and writes that list as an environment setting shell script. On Linux a call to this to you .bashrc file. Eg.
if [ -f ~/.rollrc ]; then
. roll
fi
Currently this only supports bash.
TODO: It would be better to “install” executables to an
appropriate bin dir, using links (soft if possible). There could go in
~/.bin or .config/roll/
# File lib/roll/command.rb, line 183
183: def path(args, opts)
184: case RUBY_PLATFORM
185: when /mswin/, /wince/
186: div = ';'
187: else
188: div = ':'
189: end
190: env_path = ENV['PATH'].split(/[#{div}]/)
191: # Go thru each roll lib and make sure bin path is in path.
192: binpaths = []
193: Library.list.each do |name|
194: lib = Library[name]
195: if lib.bindir?
196: binpaths << lib.bindir
197: end
198: end
199: #pathenv = (["$PATH"] + binpaths).join(div)
200: pathenv = binpaths.join(div)
201: #puts %{export PATH="#{pathenv}"}
202: puts pathenv
203: end
path_optparse(op, options)
click to toggle source
# File lib/roll/command.rb, line 104
104: def path_optparse(op, options)
105: op.banner = "Usage: roll path"
106: op.separator "Generate executable PATH list."
107: op
108: end
sync(args, opts)
click to toggle source
Synchronize ledgers.
# File lib/roll/command.rb, line 131
131: def sync(args, opts)
132: name = args.first
133: list = name ? [name] : Environment.list
134: list.each do |name|
135: result = Roll.sync(name)
136: if result
137: puts " saved #{name}"
138: else
139: puts " current #{name}"
140: end
141: end
142: end
sync_optparse(op, options)
click to toggle source
# File lib/roll/command.rb, line 80
80: def sync_optparse(op, options)
81: op.banner = "Usage: roll sync [NAME]"
82: op.separator "Synchronize ledger(s) to their respective environment(s)."
83: op
84: end
Disabled; run with --debug to generate this.