Class: Metanorma::Cli::Command
- Inherits:
-
ThorWithConfig
- Object
- Thor
- ThorWithConfig
- Metanorma::Cli::Command
- Defined in:
- lib/metanorma/cli/flavor.rb,
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
- #export_config(type = nil) ⇒ Object
- #list_doctypes(type = nil) ⇒ Object
- #list_extensions(type = nil) ⇒ Object
- #log_messages ⇒ Object
- #new(name) ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
208 209 210 |
# File 'lib/metanorma/cli/command.rb', line 208 def self.exit_on_failure? true end |
Instance Method Details
#collection(filename = nil) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/metanorma/cli/command.rb', line 112 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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/metanorma/cli/command.rb', line 74 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 [:log_messages] invoke(:log_messages, [], type: [:type], agree_to_terms: true) elsif .keys.size >= 2 UI.say("Need to specify a file to process") else invoke :help end end |
#convert(inputfile) ⇒ Object
148 149 150 151 152 |
# File 'lib/metanorma/cli/command.rb', line 148 def convert(inputfile) MnConvert.convert(inputfile, ) rescue Error => e UI.say e. end |
#export_config(type = nil) ⇒ Object
195 196 197 |
# File 'lib/metanorma/cli/command.rb', line 195 def export_config(type = nil) export_config_flavor(type) end |
#list_doctypes(type = nil) ⇒ Object
190 191 192 |
# File 'lib/metanorma/cli/command.rb', line 190 def list_doctypes(type = nil) print_doctypes_table(type) end |
#list_extensions(type = nil) ⇒ Object
185 186 187 |
# File 'lib/metanorma/cli/command.rb', line 185 def list_extensions(type = nil) single_type_extensions(type) || all_type_extensions end |
#log_messages ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/metanorma/cli/command.rb', line 172 def if [:type] Metanorma::Cli.load_flavors = ::Metanorma::Compile.new.([:type]) UI.say() else UI.say("Please specify a standard type with -t option") end rescue NameError => e UI.say(e) end |
#new(name) ⇒ Object
29 30 31 |
# File 'lib/metanorma/cli/command.rb', line 29 def new(name) create_new_document(name, ) end |
#version ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/metanorma/cli/command.rb', line 160 def version Metanorma::Cli.load_flavors backend_version([:type]) || supported_backends [:type] or dependencies_versions rescue NameError => e UI.say(e) end |