Sha256: 74ba8e729a49020ee29a42c69739fdff9e3a4eedfba18991d4a6959ebec0cf57

Contents?: true

Size: 961 Bytes

Versions: 21

Compression:

Stored size: 961 Bytes

Contents

require 'optparse'

module SystemBuilder
  class CLI
    def self.execute(stdout, arguments=[])
      options = {}
      mandatory_options = %w(config)

      OptionParser.new do |opts|
        opts.banner = <<-BANNER.gsub(/^          /,'')
          Create and configure bootable systems

          Usage: #{File.basename($0)} [options] image command

          Options are:
        BANNER
        opts.separator ""
        opts.on("-c", "--config=FILE", String,
                "The file containing image and boot definitions") { |arg| options[:config] = arg }
        opts.on("-h", "--help", "Show this help message.") { stdout.puts opts; exit }

        opts.parse!(arguments)

        if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
          stdout.puts opts; exit
        end
      end

      load options[:config]

      image = SystemBuilder.configuration(arguments.unshift)
      image.create
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
albanpeignier-system-builder-0.0.2 lib/system_builder/cli.rb
system-builder-0.0.26 lib/system_builder/cli.rb
system-builder-0.0.23 lib/system_builder/cli.rb
system-builder-0.0.22 lib/system_builder/cli.rb
system-builder-0.0.21 lib/system_builder/cli.rb
system-builder-0.0.20 lib/system_builder/cli.rb
system-builder-0.0.19 lib/system_builder/cli.rb
system-builder-0.0.18 lib/system_builder/cli.rb
system-builder-0.0.17 lib/system_builder/cli.rb
system-builder-0.0.16 lib/system_builder/cli.rb
system-builder-0.0.15 lib/system_builder/cli.rb
system-builder-0.0.14 lib/system_builder/cli.rb
system-builder-0.0.13 lib/system_builder/cli.rb
system-builder-0.0.12 lib/system_builder/cli.rb
system-builder-0.0.10 lib/system_builder/cli.rb
system-builder-0.0.9 lib/system_builder/cli.rb
system-builder-0.0.7 lib/system_builder/cli.rb
system-builder-0.0.6 lib/system_builder/cli.rb
system-builder-0.0.5 lib/system_builder/cli.rb
system-builder-0.0.4 lib/system_builder/cli.rb