Sha256: 9e6cecb3a3aac0f77c7b3160670e3e23204513dcefb45e6546348c6b5b225991

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 KB

Contents

require 'rubygems'
require 'dockly'
require 'clamp'

class Dockly::AbstractCommand < Clamp::Command
  option ['-F', '--file'], 'FILE', 'dockly file to read', :default => 'dockly.rb', :attribute_name => :file

  def execute
    if File.exist?(file)
      Dockly.load_file = file
    else
      raise 'Could not find a dockly file!'
    end
  end
end

class Dockly::BuildCommand < Dockly::AbstractCommand
  parameter 'PACKAGE', 'the name to build the package for', :attribute_name => :package_name
  option ['-f', '--force'], :flag, 'force the package build', :default => false, :attribute_name => :force

  def execute
    super
    if package = Dockly.debs[package_name.to_sym]
      if force? || !package.exists?
        package.build
      else
        puts "Package already exists!"
      end
    end
  end
end

class Dockly::ListCommand < Dockly::AbstractCommand
  def execute
    super
    Dockly.debs.each_with_index do |(name, package), index|
      puts "#{index + 1}. #{name}"
    end
  end
end

class Dockly::Cli < Dockly::AbstractCommand
  subcommand ['build', 'b'], 'Create package', Dockly::BuildCommand
  subcommand ['list', 'l'], 'List packages', Dockly::ListCommand
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dockly-1.2.1 lib/dockly/cli.rb
dockly-1.2.0 lib/dockly/cli.rb
dockly-1.1.1 lib/dockly/cli.rb
dockly-1.1.0 lib/dockly/cli.rb
dockly-1.0.0 lib/dockly/cli.rb
dockly-0.0.7 lib/dockly/cli.rb
dockly-0.0.6 lib/dockly/cli.rb
dockly-0.0.5 lib/dockly/cli.rb
dockly-0.0.4 lib/dockly/cli.rb