Class: Metanorma::Cli::Command
- Inherits:
-
ThorWithConfig
- Object
- Thor
- ThorWithConfig
- Metanorma::Cli::Command
- Defined in:
- lib/metanorma/cli/command.rb
Instance Method Summary collapse
- #collection(filename = nil) ⇒ Object
- #compile(file_name = nil) ⇒ Object
- #convert(inputfile) ⇒ Object
- #list_doctypes(type = nil) ⇒ Object
- #list_extensions(type = nil) ⇒ Object
- #new(name) ⇒ Object
- #version ⇒ Object
Instance Method Details
#collection(filename = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/metanorma/cli/command.rb', line 72 def collection(filename = nil) if filename = .dup [:compile] = () Metanorma::Cli::Collection.render(filename, ) else UI.say("Need to specify a file to process") end rescue ArgumentError => e UI.say e. end |
#compile(file_name = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/metanorma/cli/command.rb', line 45 def compile(file_name = nil) if file_name && ![:version] documents = select_wildcard_documents(file_name) || [file_name] documents.each { |document| compile_document(document, .dup) } elsif [:version] invoke(:version, [], type: [:type], format: [:format]) elsif .keys.size >= 2 UI.say("Need to specify a file to process") else invoke :help end end |
#convert(inputfile) ⇒ Object
108 109 110 111 112 |
# File 'lib/metanorma/cli/command.rb', line 108 def convert(inputfile) MnConvert.convert(inputfile, ) rescue Error => e UI.say e. end |
#list_doctypes(type = nil) ⇒ Object
133 134 135 136 137 138 139 140 141 |
# File 'lib/metanorma/cli/command.rb', line 133 def list_doctypes(type = nil) processors = backend_processors if type && processors[type.to_sym] processors = { type.to_sym => processors[type.to_sym] } end print_doctypes_table(processors) end |
#list_extensions(type = nil) ⇒ Object
126 127 128 129 130 |
# File 'lib/metanorma/cli/command.rb', line 126 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
23 24 25 |
# File 'lib/metanorma/cli/command.rb', line 23 def new(name) create_new_document(name, ) end |
#version ⇒ Object
118 119 120 121 122 123 |
# File 'lib/metanorma/cli/command.rb', line 118 def version Metanorma::Cli.load_flavors backend_version([:type]) || supported_backends rescue NameError => error UI.say(error) end |