Sha256: 7aa1cb5ff9da53166b5be533cd486be7ddc0052f90ab7438247bba60c09f3f51

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

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

require 'thor'
# require 'byebug'
require_relative '../lib/admqr_knife'

class AdmqrVisitCLI < Thor
  desc 'record', 'record a visit data'
  option :client_key, aliases: '-t', required: true, desc: 'admqr client key'
  option :ua, desc: "visitor's user agent"
  option :referer, desc: 'visitor from '
  option :tag, desc: 'project name'
  option :extra, desc: 'extra info'
  option :new_to_visit, type: :boolean, desc: 'is a new visit', default: true

  def record(unique_code)
    AdmqrKnife.init(options[:client_key])
    AdmqrKnife.visit(unique_code: unique_code,
                     client_ua: options[:ua] || options[:client_ua],
                     referer: options[:referer],
                     tag: options[:tag],
                     new_to_visit: options[:new_to_visit],
                     extra: options[:extra],
                     remote_ip: options[:remote_ip])
    AdmqrKnife.logger.debug('ok!')
  end

  desc 'help', 'Describe available commands or one specific command (aliases: `h`).'
  map Thor::HELP_MAPPINGS => :help
  def help(command = nil, subcommand = false)
    super
  end
end

AdmqrVisitCLI.start(ARGV)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
admqr_knife-0.2.0 exe/admqr_visit
admqr_knife-0.1.5 exe/admqr_visit
admqr_knife-0.1.4 exe/admqr_visit
admqr_knife-0.1.3 exe/admqr_visit