bin/caramelize in caramelize-0.3.0 vs bin/caramelize in caramelize-0.4.0

- old
+ new

@@ -1,5 +1,51 @@ #!/usr/bin/env ruby -require 'caramelize/cli' +require 'caramelize' +require 'commander/import' -Caramelize::CLI::CommandParser.new.parse \ No newline at end of file +# :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