Class: OptionsParser
- Inherits:
-
Object
- Object
- OptionsParser
- Defined in:
- lib/hiptest-publisher/options_parser.rb
Class Method Summary collapse
- .all_options ⇒ Object
- .languages ⇒ Object
- .make_language_option(lang, framework = '') ⇒ Object
- .parse(args, reporter) ⇒ Object
- .show_languages ⇒ Object
Class Method Details
.all_options ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/hiptest-publisher/options_parser.rb', line 132 def self. [ Option.new('t', 'token=TOKEN', nil, String, "Secret token (available in your project settings)", :token), Option.new('l', 'language=LANG', 'ruby', String, "Target language", :language), Option.new('f', 'framework=FRAMEWORK', '', String, "Test framework to use", :framework), Option.new('o', 'output-directory=PATH', '.', String, "Output directory", :output_directory), Option.new('c', 'config-file=PATH', nil, String, "Configuration file", :config), Option.new(nil, 'overriden-templates=PATH', '', String, "Folder for overriden templates", :overriden_templates), Option.new(nil, 'test-run-id=ID', '', String, "Export data from a test run", :test_run_id), Option.new(nil, 'scenario-ids=IDS', '', String, "Filter scenarios by ids", :filter_ids), Option.new(nil, 'scenario-tags=TAGS', '', String, "Filter scenarios by tags", :filter_tags), Option.new(nil, 'only=CATEGORIES', nil, String, "Restrict export to given file categories (--only=list to list them)", :only), Option.new('x', 'xml-file=PROJECT_XML', nil, String, "XML file to use instead of fetching it from Hiptest", :xml_file), Option.new(nil, 'tests-only', false, nil, "(deprecated) alias for --only=tests", :tests_only), Option.new(nil, 'actionwords-only', false, nil, "(deprecated) alias for --only=actionwords", :actionwords_only), Option.new(nil, 'actionwords-signature', false, nil, "Export actionwords signature", :actionwords_signature), Option.new(nil, 'show-actionwords-diff', false, nil, "Show actionwords diff since last update (summary)", :actionwords_diff), Option.new(nil, 'show-actionwords-deleted', false, nil, "Output signature of deleted action words", :aw_deleted), Option.new(nil, 'show-actionwords-created', false, nil, "Output code for new action words", :aw_created), Option.new(nil, 'show-actionwords-renamed', false, nil, "Output signatures of renamed action words", :aw_renamed), Option.new(nil, 'show-actionwords-signature-changed', false, nil, "Output signatures of action words for which signature changed", :aw_signature_changed), Option.new(nil, 'with-folders', false, nil, "Use folders hierarchy to export files in respective directories, to be used with --split-scenarios", :with_folders), Option.new(nil, 'split-scenarios', false, nil, "Export each scenario in a single file", :split_scenarios), Option.new(nil, 'leafless-export', false, nil, "Use only last level action word", :leafless_export), Option.new('s', 'site=SITE', 'https://hiptest.net', String, "Site to fetch from", :site), Option.new('p', 'push=FILE.TAP', '', String, "Push a results file to the server", :push), Option.new(nil, 'push-format=tap', 'tap', String, "Format of the test results (tap, junit, robot)", :push_format), Option.new(nil, 'sort=[id,order,alpha]', 'id', String, "Sorting of tests in output: id will sort them by age, order will keep the same order than in hiptest, alpha will sort them by name", :sort), Option.new('v', 'verbose', false, nil, "Run verbosely", :verbose) ] end |
.languages ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/hiptest-publisher/options_parser.rb', line 115 def self.languages # First framework is default framework { 'Ruby' => ['Rspec', 'MiniTest'], 'Cucumber' => ['Ruby', 'Java'], 'Java' => ['JUnit', 'Test NG'], 'Python' => ['Unittest'], 'Robot Framework' => [''], 'Selenium IDE' => [''], 'Javascript' => ['qUnit', 'Jasmine', 'Mocha'], 'CSharp' => ['NUnit'], 'PHP' => ['PHPUnit'], 'SpecFlow' => [''] } end |
.make_language_option(lang, framework = '') ⇒ Object
213 214 215 216 217 218 |
# File 'lib/hiptest-publisher/options_parser.rb', line 213 def self.make_language_option(lang, framework = '') lang_opt = "--language=#{lang.downcase.gsub(' ', '')}" framework_opt = "--framework=#{framework.downcase.gsub(' ', '')}" framework.empty? ? lang_opt : "#{lang_opt} #{framework_opt}" end |
.parse(args, reporter) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/hiptest-publisher/options_parser.rb', line 164 def self.parse(args, reporter) = CliOptions.new opt_parser = OptionParser.new do |opts| opts.version = hiptest_publisher_version if hiptest_publisher_version opts. = "Usage: ruby publisher.rb [options]" opts.separator "" opts.separator "Exports tests from Hiptest for automation." opts.separator "" opts.separator "Specific options:" .each {|o| o.register(opts, )} opts.on("-H", "--languages-help", "Show languages and framework options") do self.show_languages exit end opts.on("-F", "--filters-help", "Show help about scenario filtering") do [ "hiptest-publisher allows you to filter the exported scenarios.", "You can select the ids of the scenarios:", "hiptest-publisher --scenario-ids=12", "hiptest-publisher --scenario-ids=12,15,16", "", "You can also filter by tags:", "hiptest-publisher --scenario-tags=mytag", "hiptest-publisher --scenario-tags=mytag,myother:tag", "", "You can not mix ids and tag filtering, only the id filtering will be applied." ].each {|line| puts line} exit end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end args << "--help" if args.empty? opt_parser.parse!(args) reporter.add_listener(ConsoleFormatter.new(.verbose)) FileConfigParser.(, reporter) reporter.(.marshal_dump) .normalize!(reporter) end |
.show_languages ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/hiptest-publisher/options_parser.rb', line 220 def self.show_languages puts "Supported languages:" languages.each do |language, frameworks| puts "#{language}:" if frameworks.empty? puts " no framework option available #{make_language_option(language, '')}" else frameworks.each_with_index do |fw, index| if index == 0 puts " - #{fw} [default] #{make_language_option(language, '')}" else puts " - #{fw} #{make_language_option(language, fw)}" end end end end end |