Sha256: 4c485da0c6c8154b4908e3887c3cb9a4ce0d46214bd5d218f512abd881fe52d4

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 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
rescue Netprint::UploadError => e
  abort '%s: %s' % [$0, e.message]
rescue Netprint::RegistrationError => e
  abort '%s: A registration error occured' % $0
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netprint-0.3.4 bin/netprint
netprint-0.3.3 bin/netprint