Sha256: 01bdf67a29b02f62701643d0244c99ed24fb48395cc465a40cdc51a254dc0b9b

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 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))
      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
      end.parse!(arguments)
      options
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timex_datalink_caldav-0.2.0 lib/timex_datalink_caldav.rb