Class: Asciidoctor::ConfluencePublisher::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor/confluence_publisher/command.rb

Class Method Summary collapse

Class Method Details

.execute(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/asciidoctor/confluence_publisher/command.rb', line 7

def self.execute(args)
  options = Asciidoctor::Cli::Options.new

  unless args != ['-v'] && (args & ['-V', '--version']).empty?
    $stdout.write %(Asciidoctor Confluence #{Asciidoctor::ConfluencePublisher::VERSION} using )
    options.print_version
    exit 0
  end

  orig_args = args.dup
  # if the parameter is a directory, it will set to the root of source_file
  source_dir = nil
  2.times do
    result = options.parse! args
    break unless result.is_a? Integer

    can_retry = false
    if args.size == 1
      source_dir = args.first
      args = convert_directory_to_files(source_dir, orig_args)
      can_retry = true
    end
    exit result unless can_retry
  end

  options[:asciidoc_source_dir] = source_dir
  invoker = Asciidoctor::ConfluencePublisher::Invoker.new options
  GC.start
  invoker.invoke!
end