Class: LxcForge::Options
- Inherits:
-
Object
- Object
- LxcForge::Options
- Defined in:
- lib/lxc_forge/options.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
- #parse ⇒ Object
- #parser ⇒ Object
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
7 8 9 10 |
# File 'lib/lxc_forge/options.rb', line 7 def initialize(argv) @argv = argv @options = {} end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/lxc_forge/options.rb', line 5 def @options end |
Instance Method Details
#parse ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lxc_forge/options.rb', line 38 def parse parser.parse!(@argv) if @argv.length == 0 puts parser.help exit 0 elsif @argv.length == 1 [:command] = @argv.first else raise ArgumentError.new "Multiple actions not supported" end end |
#parser ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lxc_forge/options.rb', line 12 def parser OptionParser.new do |opts| opts. = "Usage: lxc-forge ACTION [options] Actions: configure - Configure LXC Forge settings upload - Upload an LXC container to S3 download - Download an LXC container from S3 list - List available containers on S3 " opts.on("-n NAME", "--name NAME", "Set container name") do |v| [:name] = v end opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| [:verbose] = v end opts.on("-f", "--[no-]force", "Force overwrite") do |v| [:force] = v end end end |