Sha256: edcc33a84575e4f2e3defe0a908b31d3b41fc9685c4fcd3dc42f0f16d863dfdb

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

#!/usr/bin/env ruby
# RemoTransmission command line interface to control
# a remote transmission client.

require 'choice'
require 'remotransmission'

defaults = RemoTransmission::default_options("~/.config/remotransmission/settings.json")

Choice.options do
  banner "RemoTransmission v#{RemoTransmission::VERSION}\n"
  banner "Usage: remotransmission [options...] <command>"
  header ''
  header 'Commands:'
  option :add do
    short '-a'
    long '--add=URL'
    desc 'Add a torrent by its URL'
  end

  option :list do
    short '-l'
    long '--list'
    desc "List current torrents"
  end

  separator ""
  separator 'Options:'
  option :host do
    long '--host=IP'
    desc "The hostname or ip of the server to connect to (default #{defaults[:host].inspect})"
    default defaults[:host]
  end

  option :port do
    long '--port=PORT'
    desc "The port to bind to (default #{defaults[:port].inspect})"
    cast Integer
    default defaults[:port]
  end

  option :user do
    short '-u'
    long '--user=USER'
    desc "User to authenticate (default #{defaults[:user].inspect})"
    default 'freebox'
    default defaults[:user]
  end

  option :password do
    short '-p'
    long '--password=PASSWORD'
    desc "Password to authenticate"
    default defaults[:password]
  end

  option :debug do
    short '-d'
    long '--debug'
    desc "Enable debug mode"
    default defaults[:debug]
  end

  separator ""
  separator "Examples:"
  separator "    $ #{File.basename($0)} --add 'magnet://...'"
  separator "    success"
  separator "    $ #{File.basename($0)} -p PaSsWord --host 192.168.0.254 --list"
  separator "    100% - ubuntu-10.10-desktop-i386.iso"
  separator "    100% - ubuntu-10.10-server-i386.iso"
end


options = {
  host: Choice[:host],
  port: Choice[:port],
  user: Choice[:user],
  password: Choice[:password],
  debug: Choice[:debug]
}

client = RemoTransmission::Client.new(options)

if Choice[:add]
  client.add(Choice[:add])
elsif Choice[:list]
  client.list
else
  Choice.help
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
remotransmission-1.0.2 bin/remotransmission
remotransmission-1.0.1 bin/remotransmission