Sha256: 3b87f058ec04acb51d9b5b10c40c7f7e6d66c8b00f08b31dcf879cf728681a3b

Contents?: true

Size: 642 Bytes

Versions: 2

Compression:

Stored size: 642 Bytes

Contents

# -*- coding: utf-8 -*-
require 'usbutils'
require 'thor'

module USBUtils
  class CLI < Thor
    desc "devices", "list all usb devices"
    option :detail, :aliases => "d"
    def devices
      devices = USBUtils.devices
      USBUtils.devices.each do |device|
        if options[:detail]
          pp device
        else
          print "serial=#{device[:serial]}\tproduct=#{device[:product]}\tmanufacturer=#{device[:manufacturer]}\n"
        end
      end
    end

    desc "reset <serial no>", "reset device"
    def reset(serial)
      device = USBUtils.find_by(:serial, serial)
      device[:usbdev].open.reset_device
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
usbutils-0.0.3 lib/usbutils/cli.rb
usbutils-0.0.2 lib/usbutils/cli.rb