Sha256: 8147e518a971b0ca915591a451f0687ba9415f0ab8cbd7e1e3745b6f306f1216

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

module Brightbox
  class CommandGenerator
    COMMAND_LIST = [
      'brightbox-accounts',
      'brightbox-cloudips',
      'brightbox-config',
      'brightbox-groups',
      'brightbox-images',
      'brightbox-lbs',
      'brightbox-servers',
      'brightbox-firewall-policies',
      'brightbox-firewall-rules',
      '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

10 entries across 10 versions & 1 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.18.0 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.17.5 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.17.4 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.17.3 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.17.2 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.17.1 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.17.0 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.16.0 lib/brightbox-cli/command_generator.rb
brightbox-cli-0.15.0 lib/brightbox-cli/command_generator.rb