Sha256: 2b963aee3541d5852cd80a22dbad396802089894f53754ff0a6fcd5df360cfda

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby

require 'netprint'
require 'docopt'

program_name = File.basename($0)
doc =<<-EOS
Usage:
  #{program_name} [--user=<userid:password>] [--email=<email>] [--secret=<secret>] <filename>
  #{program_name} -h | --help

Options:
  -h --help                    Show this screen.
  -v --version                 Show version information.
  -u --user=<userid:password>  User account. If not specified, ENV['NETPRINT_(USERID|PASSWORD)'] is used.
  -e --email=<email>           Email address to notify. If not specified, ENV['NETPRINT_EMAIL'] is used.
  -s --secret=<secret>         Secret code.
EOS

begin
  options          = Docopt::docopt(doc, :version => Netprint::VERSION)
  userid, password = options['--user'].split(':') if options['--user']
  netprint         = Netprint::Agent.new(
    userid   || ENV['NETPRINT_USERID'],
    password || ENV['NETPRINT_PASSWORD'])

  netprint.login
  code = netprint.upload(options['<filename>'],
    :email       => options['--email'] || ENV['NETPRINT_EMAIL'],
    :color       => Netprint::COLOR::SELECT_WHEN_PRINT,
    :secret_code => options['--secret'])

  puts code
rescue Docopt::Exit => e
  puts e.message
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netprint-0.3.0 bin/netprint
netprint-0.2.0 bin/netprint