Sha256: 525f601f53bc86d599b2e3a4bddbeca6b1bfd31e995d2b6a2c3559bcc842400d
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
#!/usr/bin/env ruby require "how_is" require "optparse" options = { repository: nil, report_file: "report.pdf", from_file: nil, use_config_file: false, config_file: nil, } opts = OptionParser.new do |opts| opts.banner = <<-EOF.gsub(/ *\| ?/, '') | Usage: how_is REPOSITORY [--report REPORT_FILE] | | Where REPOSITORY is of the format <GitHub username or org>/<repository name>. | | E.g., if you wanted to check https://github.com/duckinator/how_is, | you'd run `how_is duckinator/how_is`. | EOF opts.separator "" opts.separator "Options:" opts.on("-h", "--help", "Print this help") do puts opts exit 0 end opts.on("--config [YAML_CONFIG_FILE]", "generate reports as specified in YAML_CONFIG_FILE") do |file| options[:use_config_file] = true options[:config_file] = file end opts.on("--from JSON_REPORT_FILE", "import JSON_REPORT_FILE instead of fetching the data again") do |file| options[:from_file] = file end opts.on("--report REPORT_FILE", "file containing the report") do |file| options[:report_file] = file end opts.on("-v", "--version", "prints the version") do puts HowIs::VERSION exit end end opts.parse! if options[:use_config_file] HowIs::CLI.new.from_config_file(options[:config_file]) exit end unless HowIs.can_export_to?(options[:report_file]) abort "Invalid file: #{options[:report_file]}. Supported formats: #{HowIs.supported_formats.join(', ')}" end if options[:from_file] # Opening this file here seems a bit messy, but it works. options[:repository] = JSON.parse(open(options[:from_file]).read)['repository'] abort "Error: Invalid JSON report file." unless options[:repository] elsif ARGV.length >= 1 options[:repository] = ARGV.delete_at(0) else abort "Error: No repository specified." end HowIs.generate_report_file(options)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
how_is-7.0.0 | exe/how_is |