Class: Warehaus::CLI
- Inherits:
-
Object
- Object
- Warehaus::CLI
- Defined in:
- lib/warehaus.rb
Instance Method Summary collapse
- #help(method = "none") ⇒ Object
-
#initialize(args) ⇒ CLI
constructor
A new instance of CLI.
- #json(args) ⇒ Object
- #set_options ⇒ Object
- #unbox(args) ⇒ Object
- #v ⇒ Object
Constructor Details
#initialize(args) ⇒ CLI
Returns a new instance of CLI.
146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/warehaus.rb', line 146 def initialize(args) = args .select{|arg| (arg =~ /^\-/) != nil} .map{|arg| arg.gsub(/^\-/,'')} stripped_args = args.reject{|arg| (arg =~ /^\-/) != nil} @method = stripped_args[0] @arguments = stripped_args[1..-1] self.send(@method, @arguments) end |
Instance Method Details
#help(method = "none") ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/warehaus.rb', line 182 def help(method="none") puts "\nWAREHAUS\n\nNAME\n warehaus\n\nSYNOPSIS\n warehouse COMMAND [-v] [ARGS]\n\nDESCRIPTION\n Takes URLS or IDs for Sketchup Warehouse models, grabs their collada \n resources, and unpacks them into a target directory\n\nOPTIONS\n -v\nPrints logging and debug information\n\nWAREHAUS COMMANDS\n unbox [identifier] [path=./] [name=warehouse_model]\nUnpacks Sketchup model identified by [identifier] to [path]/[name]/[name].dae\n json [path]\n[path] is a path to a json file to parse and use for unboxing. see the\ngithub docs for information on the strucure of this file\n help\nprints help\n\n" end |
#json(args) ⇒ Object
163 164 165 166 167 168 169 170 171 |
# File 'lib/warehaus.rb', line 163 def json(args) File.open(args[0]) do |file| @json = JSON.parse(file.read, :symbolize_names => true) end Warehaus::Getter.from_hash(@json) end |
#set_options ⇒ Object
159 160 161 |
# File 'lib/warehaus.rb', line 159 def .each{ |opt| self.send(opt)} end |
#unbox(args) ⇒ Object
177 178 179 180 |
# File 'lib/warehaus.rb', line 177 def unbox(args) fetcher = Warehaus::Getter.new(*args) fetcher.unbox end |
#v ⇒ Object
173 174 175 |
# File 'lib/warehaus.rb', line 173 def v $mode = "verbose" end |