Sha256: a9f033bd7f24d235dad0f746434c64348a99f5c1a3e397d3cce487c77eb2c599

Contents?: true

Size: 1.27 KB

Versions: 18

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'optparse'

require 'user_agent_parser'
require 'user_agent_parser/cli'

options = {}

optparse = OptionParser.new do |opts|
  opts.on('--family', 'Print family only') do
    options[:family] = true
  end

  opts.on('--name', 'Print name (alias for family) only') do
    options[:family] = true
  end

  opts.on('--version', 'Print version only') do
    options[:version] = true
  end

  opts.on('--major', 'Print major version only') do
    options[:major] = true
  end

  opts.on('--minor', 'Print minor version only') do
    options[:minor] = true
  end

  opts.on('--os', 'Print operating system only') do
    options[:os] = true
  end

  opts.on('--format format',
          'Print output in specified format. The available formatters are:',
          ' - %f: family',
          ' - %n: name (alias for family)',
          ' - %v: version',
          ' - %M: major version',
          ' - %m: minor version',
          ' - %o: operating system'
         ) do |format|
    options[:format] = format
  end

  opts.on('-h', '--help', 'Display this screen') do
    puts opts
    exit
  end
end

optparse.parse!

parser = UserAgentParser::Parser.new

ARGF.each do |line|
  puts UserAgentParser::Cli.new(parser.parse(line), options).run!
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
user_agent_parser-2.18.0 bin/user_agent_parser
user_agent_parser-2.17.0 bin/user_agent_parser
user_agent_parser-2.16.0 bin/user_agent_parser
user_agent_parser-2.15.0 bin/user_agent_parser
user_agent_parser-2.14.0 bin/user_agent_parser
user_agent_parser-2.13.0 bin/user_agent_parser
user_agent_parser-2.12.0 bin/user_agent_parser
user_agent_parser-2.11.0 bin/user_agent_parser
user_agent_parser-2.10.0 bin/user_agent_parser
user_agent_parser-2.9.0 bin/user_agent_parser
user_agent_parser-2.8.0 bin/user_agent_parser
user_agent_parser-2.7.0 bin/user_agent_parser
user_agent_parser_livelink-2.6.0 bin/user_agent_parser
user_agent_parser-2.6.0 bin/user_agent_parser
user_agent_parser-2.5.3 bin/user_agent_parser
user_agent_parser-2.5.2 bin/user_agent_parser
user_agent_parser-2.5.1 bin/user_agent_parser
user_agent_parser-2.5.0 bin/user_agent_parser