Sha256: 4dccef88587f63d150ed21502f6369d50da3edc6cf4b6ec233ce4ea1ff0f21ab

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

require 'optparse'
require 'torrific'

module Torrific
  class Application
    class << self
      attr_accessor :password, :port, :host
      def run
        self.parse_options

        tor = TorControl.new(host: self.host, port: self.port, password: self.password)
        tor.change_ip
      end

      def parse_options
        options = OptionParser.new do |opts|
          opts.banner = "Usage: torrific [options]"

          opts.on("--password PASSWORD",
                  "Sets the authentication password(default is nil)") do |pass=nil|
            self.password = pass
          end

          opts.on("--host HOST", "Tor Control host(default is localhost)") do |host='127.0.0.1'|
            self.host = host
          end

          opts.on("--port PORT",
                  "Tor Control port(default is 9051).") do |port=9051|
            self.port = port
          end
        end

        options.parse!
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
torrific-0.0.2 lib/application.rb
torrific-0.0.1 lib/application.rb