gocal

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2016 License: MIT Imports: 6 Imported by: 1

README

gocal

Simple cli tool for google calendar api.

Usage

usage: gocal [<flags>] <command> [<args> ...]

google calendar events api

Flags:
      --help     Show context-sensitive help (also try --help-long and --help-man).
  -c, --conf="$HOME/.config/gocal/calendar.toml"  
                 config file
      --version  Show application version.

Commands:
  help [<command>...]
    Show help.

  events list [<flags>]
    insert google calendar events

  events insert --name=NAME [<flags>]
    insert google calendar events

Insert events from JSON file

gocal supports to insert from JSON file.

$ gocal events insert --from-json /path/to/jsonfile.json

example JSON:

[
  {
      "title": "input title",
      "detail": "input a description in this field"
  },
  ...
]

Config

The format is toml, and default path is $HOME/.config/gocal/calendar.toml.

calendar_id = "your calendar id"
credential_file = "/path/to/credential_file.json"

You can create credential_file.json on Google API Console at Service Account Manager.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CalendarID string `toml:"calendar_id"`
	Credential string `toml:"credential_file"`
}

Config contains user calendar config.

func LoadConfig

func LoadConfig(fp string) (Config, error)

LoadConfig returns user google calendar config.

type Event

type Event struct {
	Title     string `json:"title"`
	Detail    string `json:"detail"`
	StartTime string `json:"start_time"`
	EndTime   string `json:"end_time"`
}

Event is google calendar event at Gocal

type Gocal added in v0.0.2

type Gocal interface {
	GetEventsList(string, string) (*calendar.Events, error)
	InsertEvent(Event) error
	InsertEvents([]Event)
}

Gocal is interface for google calendar api

type GocalClient

type GocalClient struct {
	Srv  *calendar.Service
	Conf Config
}

GocalClient is a google calenar api client

func NewCalendarClient

func NewCalendarClient(c Config, scope string) (*GocalClient, error)

NewCalendarClient returns http client google calandar api scope is calendar.CalendarReadonlyScope or calendar.CalendarScope

func (GocalClient) GetEventsList

func (gc GocalClient) GetEventsList(startTime string, endTime string) (*calendar.Events, error)

GetEventsList returns event list

func (GocalClient) InsertEvent

func (gc GocalClient) InsertEvent(event Event) error

InsertEvent insert an event to the google calendar

func (GocalClient) InsertEvents added in v0.0.2

func (gc GocalClient) InsertEvents(events []Event)

InsertEvents insert multiple events

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL