Sha256: df7b201d0ed0d644f61237594ad26f811865761b4fad80d98f1405a99a5414b5

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true
require 'optparse'
require_relative "timex_datalink_caldav/client"

module TimexDatalinkCaldav
  class CLI
    def initialize(arguments)
      @options = parse_options(arguments)
    end

    def execute
      client = TimexDatalinkCaldav::Client.new(@options.fetch(:user), @options.fetch(:password), @options.fetch(:uri), @options.fetch(:device), @options.fetch(:api,1))
      client.sync_to_watch
    end

    private

    def parse_options(arguments)
      options = {}
      OptionParser.new do |opts|
        opts.banner = "Usage: timex_datalink_caldav [options]"

        opts.on("-u", "--uri URI", "CalDAV server URI") do |v|
          options[:uri] = v
        end

        opts.on("-n", "--user USERNAME", "Username for CalDAV server") do |v|
          options[:user] = v
        end

        opts.on("-p", "--password PASSWORD", "Password for CalDAV server") do |v|
          options[:password] = v
        end

        opts.on("-d", "--device DEVICE", "Serial device for Timex Datalink watch") do |v|
          options[:device] = v
        end

        opts.on("-a", "--api PROTOCOL_VERSION", "Protocol Version") do |v|
          options[:api] = v
        end
      end.parse!(arguments)
      options
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timex_datalink_caldav-0.3.0 lib/timex_datalink_caldav.rb