class Asciidoctor::Confluence::Options

Constants

HOST_MISSING
SPACE_KEY_MISSING
TITLE_MISSING

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method
# File lib/asciidoctor/confluence/options.rb, line 13
def initialize(options = {})
  super options
  self[:confluence] = options[:confluence] || {:update => false}
  self[:confluence][:auth] = {} if self[:confluence][:auth].nil?
end
parse!(*args) click to toggle source
# File lib/asciidoctor/confluence/options.rb, line 88
def self.parse! (*args)
  Options.new.parse! args.flatten
end

Public Instance Methods

check_mandatory_options() click to toggle source
# File lib/asciidoctor/confluence/options.rb, line 82
def check_mandatory_options
  raise HOST_MISSING if self[:confluence][:host].nil?
  raise SPACE_KEY_MISSING if self[:confluence][:space_key].nil?
  raise TITLE_MISSING if self[:confluence][:title].nil?
end
init_options(args) click to toggle source
# File lib/asciidoctor/confluence/options.rb, line 31
      def init_options(args)
        opts_parser = ::OptionParser.new do |opts|
          opts.banner = <<-EOS
Usage: asciidoctor-confluence --host HOSTNAME --spaceKey SPACEKEY --title TITLE [ASCIIDOCTOR OPTIONS]...  FILE...
          EOS

          opts.on('--host HOST', 'the hostname of the Confluence instance ') do |host|
            self[:confluence][:host] = host
          end

          opts.on('--spaceKey SPACEKEY', 'the Confluence space within the page will be created') do |spaceKey|
            self[:confluence][:space_key] = spaceKey
          end

          opts.on('--title TITLE', 'the title of the Confluence page') do |title|
            self[:confluence][:title] = title
          end

          opts.on('--pageid PAGEID', 'the id of the page to update') do |page_id|
            self[:confluence][:page_id] = page_id
            end

          opts.on('--update', 'indicate that the page must be updated instead of created') do
            self[:confluence][:update] = true
          end

          opts.on('--username USERNAME', 'the username used if credential are need to create the page') do |spaceKey|
            self[:confluence][:auth][:username] = spaceKey
          end

          opts.on('--password PASSWORD', 'the password used if credential are need to create the page') do |spaceKey|
            self[:confluence][:auth][:password] = spaceKey
          end

          opts.on_tail('-h', '--help', 'Show the full helper (including Asciidoctor helper)') do
            $stdout.puts opts, "\n\n"
            return Asciidoctor::Cli::Options.parse! ['-h']
          end

          opts.on_tail('-V', '--version', 'display the version and runtime environment (or -v if no other flags or arguments)') do
            $stdout.puts "Asciidoctor-confluence v#{Asciidoctor::Confluence::VERSION}\n"
            return Asciidoctor::Cli::Options.parse! ['-V']
          end

        end

        opts_parser.parse! args
        check_mandatory_options
      end
parse!(args) click to toggle source
Calls superclass method
# File lib/asciidoctor/confluence/options.rb, line 19
def parse!(args)
    init_options args
    unless args.empty?
      base_options = super args
      if (base_options.is_a? ::Integer) && base_options == -1
        $stderr.puts 'There are some issue with the asciidoctor command'
      end
    end

    self
end