Class: Metanorma::Cli::Command
- Inherits:
-
ThorWithConfig
- Object
- Thor
- ThorWithConfig
- Metanorma::Cli::Command
- Defined in:
- lib/metanorma/cli/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #collection(filename = nil) ⇒ Object
-
#compile(file_name = nil) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/AbcSize.
- #convert(inputfile) ⇒ Object
- #list_doctypes(type = nil) ⇒ Object
- #list_extensions(type = nil) ⇒ Object
- #new(name) ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
188 189 190 |
# File 'lib/metanorma/cli/command.rb', line 188 def self.exit_on_failure? true end |
Instance Method Details
#collection(filename = nil) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/metanorma/cli/command.rb', line 105 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
rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/AbcSize
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/metanorma/cli/command.rb', line 70 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
141 142 143 144 145 |
# File 'lib/metanorma/cli/command.rb', line 141 def convert(inputfile) MnConvert.convert(inputfile, ) rescue Error => e UI.say e. end |
#list_doctypes(type = nil) ⇒ Object
169 170 171 172 173 174 175 176 177 |
# File 'lib/metanorma/cli/command.rb', line 169 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
162 163 164 165 166 |
# File 'lib/metanorma/cli/command.rb', line 162 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
28 29 30 |
# File 'lib/metanorma/cli/command.rb', line 28 def new(name) create_new_document(name, ) end |
#version ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/metanorma/cli/command.rb', line 153 def version Metanorma::Cli.load_flavors backend_version([:type]) || supported_backends [:type] or dependencies_versions rescue NameError => e UI.say(e) end |