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



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

def compile(file_name = nil)
  if file_name && !options[:version]
    Metanorma::Cli.load_flavors
    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



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

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

#setupObject



78
79
80
81
82
83
84
85
# File 'lib/metanorma/cli/command.rb', line 78

def setup
  Metanorma::Cli::REQUIRED_FONTS.each do |font|
    Metanorma::Cli::Setup.run(
      font: font,
      term_agreement: options[:agree_to_terms],
    )
  end
end

#versionObject



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

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