Sha256: 862bb3cfd24c3127ea5a0f30eedfa7550d95408adcab90912781539ceff21de5

Contents?: true

Size: 1016 Bytes

Versions: 4

Compression:

Stored size: 1016 Bytes

Contents

module Brightbox
  class CommandGenerator
    COMMAND_LIST = [
      'brightbox-accounts',
      'brightbox-cloudips',
      'brightbox-config',
      'brightbox-images',
      'brightbox-lbs',
      'brightbox-servers',
      'brightbox-types',
      'brightbox-users',
      'brightbox-zones'
    ]

    def initialize(brightbox_cli_path)
      @brightbox_cli_path = brightbox_cli_path
      COMMAND_LIST.each do |command|
        File.open("#{cli_binary_path}/#{command}","w+") do |fl|
          fl.write(command_template)
        end
      end
    end

    private
    def command_template
      brightbox_command =<<-EOF
#!/usr/bin/env ruby

begin
  require "brightbox_cli"
rescue LoadError
  brightbox_cli_path = File.expand_path('../../lib', __FILE__)
  $:.unshift(brightbox_cli_path)
  require "brightbox_cli"
end

Brightbox::BBConfig.config do
  include GLI
  run ARGV
end
      EOF
      brightbox_command
    end

    def cli_binary_path
      File.join(@brightbox_cli_path,"..","bin")
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brightbox-cli-0.14.1 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.14.0 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.13.1 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.13.0 lib/brightbox-cli/command_generator.rb