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) ⇒ Object
- .show_languages ⇒ Object
- .show_options(options) ⇒ Object
Class Method Details
.all_options ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/hiptest-publisher/options_parser.rb', line 71 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', 'config', String, "Configuration file", :config), 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, 'tests-only', false, nil, "Export only the tests", :tests_only), Option.new(nil, 'actionwords-only', false, nil, "Export only the actionwords", :actionwords_only), 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://www.hiptest-testing.com', String, "Site to fetch from", :site), Option.new('v', 'verbose', false, nil, "Run verbosely", :verbose) ] end |
.languages ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/hiptest-publisher/options_parser.rb', line 59 def self.languages # First framework is default framework { 'Ruby' => ['Rspec', 'MiniTest'], 'Java' => ['JUnit', 'Test NG'], 'Python' => ['Unittest'], 'Robot Framework' => [''], 'Selenium IDE' => [''] } end |
.make_language_option(lang, framework = '') ⇒ Object
139 140 141 142 143 144 |
# File 'lib/hiptest-publisher/options_parser.rb', line 139 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) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/hiptest-publisher/options_parser.rb', line 89 def self.parse(args) = OpenStruct.new opt_parser = OptionParser.new do |opts| 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 opt_parser.parse!(args) FileConfigParser. () if .verbose end |
.show_languages ⇒ Object
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 146 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 |
.show_options(options) ⇒ Object
134 135 136 137 |
# File 'lib/hiptest-publisher/options_parser.rb', line 134 def self.() puts "Running Hiptest-publisher with:".yellow .marshal_dump.each { |k, v| puts " - #{k}: #{v}".white } end |