Sha256: b9b1ff6d2824359b6a42e34a9eb2ca68fca1e022a6c2984904b520f17d3a6018

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

#!/usr/bin/env ruby

require 'caramelize'
require 'commander/import'

# :name is optional, otherwise uses the basename of this executable
program :name, 'caramelize'
program :version, Caramelize::VERSION
program :description, 'TODO'
program :help, 'Author', 'Daniel Senff <public@danielsenff.de>'

default_command :run

global_option '--verbose'

command :new do |c|
  c.syntax = 'caramelize create [options]'
  c.summary = 'Create new configuration'
  c.description = 'Create a fresh configuration file for caramelize'
  c.option '--config STRING', String, 'The config file (default: caramel.rb)'
  c.example 'Create a fresh config file as "caramel.rb"', 'caramelize create'
  c.example 'Create a fresh config file as "config.rb"', 'caramelize create --config config.rb'
  c.action do |args, options|
    target_file ||= (options.config || 'caramel.rb')
    options.default({ config: 'caramel.rb' })
    FileUtils.cp(File.dirname(__FILE__) + '/../lib/caramelize/caramel.rb',
                 options.config)
    say "Created new configuration file: #{optinos.config}"
  end
end
alias_command :create, :new

command :run do |c|
  c.syntax = 'caramelize run [options]'
  c.summary = 'Run wiki transfer'
  c.description = 'Run the wiki content transfer based on the given configuration file'
  c.option '--config STRING', String, 'The config file (default: caramel.rb)'
  c.example 'Run transfer for "caramel.rb"', 'caramelize run'
  c.example 'Run transfer for "config.rb"', 'caramelize run --config config.rb'
  c.action do |args, options|
    time_start = Time.now
    options.default({ config: 'caramel.rb' })
    puts options.inspect

    instance_eval(File.read(options.config))

    wiki_options = input_wiki.options.merge(verbose: options.verbose)
    Caramelize::ContentTransferer.new(input_wiki, wiki_options).execute
    say "Time required: #{Time.now - time_start} s"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caramelize-0.4.0 bin/caramelize