Sha256: c36ff142c97a84e3dd2b331e5d42b885abb357f396fbded92dd333af569a0472

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'caramelize/cli'
require 'fileutils'

module Caramelize::CLI

  # The CLI command for creating a caramelize config file.
  class CreateCommand < CmdParse::Command

    # The website config-file. Default: the current working directory.
    attr_reader :config_file

    def initialize #:nodoc:
      super('create', false)
      self.description = "If the verbosity level is set to verbose, the created files are listed."
      self.short_desc = 'Create a default config file for caramelize'
      self.options = CmdParse::OptionParserWrapper.new do |opts|
        opts.separator "Arguments:"
        opts.on("--config <file>", "-f", String, "The config file (default: caramel.rb)") {|p| @config_file = p}
      end
    end

    def usage # :nodoc:
      "Usage: #{commandparser.program_name} [global options] create [options]"
    end

    # Create a caramelize config file.
    def execute(args)
      # create dummy config file
      target_file = @config_file.nil? ? "caramel.rb" : @config_file
      FileUtils.cp(File.dirname(__FILE__) +"/../caramel.rb", target_file)
      if commandparser.verbosity == :normal
        puts "Created new configuration file: #{target_file}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caramelize-0.3.0 lib/caramelize/cli/create_command.rb