Class: StaticFM::CommandLine
- Inherits:
-
Object
- Object
- StaticFM::CommandLine
- Defined in:
- lib/static_fm/command_line.rb
Instance Method Summary collapse
- #default_options ⇒ Object
- #execute ⇒ Object
-
#initialize(args) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #install(asset_name, destination) ⇒ Object
- #list ⇒ Object
- #method ⇒ Object
- #options ⇒ Object
- #parser ⇒ Object
Constructor Details
#initialize(args) ⇒ CommandLine
Returns a new instance of CommandLine.
8 9 10 11 |
# File 'lib/static_fm/command_line.rb', line 8 def initialize(args) parser.parse!(args) # remove switches destructively @args = args end |
Instance Method Details
#default_options ⇒ Object
17 18 19 20 21 |
# File 'lib/static_fm/command_line.rb', line 17 def { :compressed => false } end |
#execute ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/static_fm/command_line.rb', line 27 def execute case method when :install install @args[1], @args[2] when :list list else parser.help end end |
#install(asset_name, destination) ⇒ Object
38 39 40 |
# File 'lib/static_fm/command_line.rb', line 38 def install(asset_name, destination) Installer.download(asset_name, destination, .merge()) end |
#list ⇒ Object
42 43 44 |
# File 'lib/static_fm/command_line.rb', line 42 def list Asset.recipe_names.join("\n") end |
#method ⇒ Object
23 24 25 |
# File 'lib/static_fm/command_line.rb', line 23 def method @args.any? && @args[0].to_sym end |
#options ⇒ Object
13 14 15 |
# File 'lib/static_fm/command_line.rb', line 13 def @options ||= {} end |
#parser ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/static_fm/command_line.rb', line 46 def parser @parser ||= OptionParser.new do |opts| opts. = "Usage: static [options] COMMAND" opts.separator "" opts.separator "Options:" opts.on("-c", "--compressed", "Retrieve compressed version") do |host| [:compressed] = true end opts.separator "" opts.separator "Commands:" opts.separator " install ASSET DEST Downloads asset to destination" opts.separator " list Lists available download recipes" end end |