Class: Metanorma::Cli::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/metanorma/cli/command.rb

Instance Method Summary collapse

Instance Method Details

#compile(file_name = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/metanorma/cli/command.rb', line 32

def compile(file_name = nil)
  if file_name && !options[:version]
    Metanorma::Cli::Compiler.compile(file_name, options.dup)

  elsif options[:version]
    invoke(:version, [], type: options[:type], format: options[:format])

  elsif options.keys.size >= 2
    UI.say("Need to specify a file to process")

  else
    invoke :help
  end
end

#list_extensions(type = nil) ⇒ Object



60
61
62
63
64
# File 'lib/metanorma/cli/command.rb', line 60

def list_extensions(type = nil)
  single_type_extensions(type) || all_type_extensions
rescue LoadError
  UI.say("Couldn't load #{type}, please provide a valid type!")
end

#new(name) ⇒ Object



16
17
18
# File 'lib/metanorma/cli/command.rb', line 16

def new(name)
  create_new_document(name, options.dup)
end

#versionObject



51
52
53
54
55
56
57
# File 'lib/metanorma/cli/command.rb', line 51

def version
  if options[:format] == :asciidoc
    backend_version(options[:type]) || supported_backends
  end
rescue NameError => error
  UI.say(error)
end