diff --git a/cmd/icarus.go b/cmd/icarus.go index 95c6120..509d606 100644 --- a/cmd/icarus.go +++ b/cmd/icarus.go @@ -3,11 +3,11 @@ package main import ( "fmt" "github.com/akamensky/argparse" + "github.com/dploeger/icarus/pkg/outputTypes" + "github.com/dploeger/icarus/pkg/processors" "github.com/emersion/go-ical" "github.com/sirupsen/logrus" "github.com/thoas/go-funk" - "icarus/pkg/outputTypes" - "icarus/pkg/processors" "os" "regexp" "time" diff --git a/go.mod b/go.mod index 058cda3..e622bd1 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,13 @@ -module icarus +module github.com/dploeger/icarus -go 1.19 +go 1.21 require ( github.com/akamensky/argparse v1.4.0 github.com/emersion/go-ical v0.0.0-20220601085725-0864dccc089f github.com/olekukonko/tablewriter v0.0.5 - github.com/sirupsen/logrus v1.9.0 - github.com/stretchr/testify v1.7.0 + github.com/sirupsen/logrus v1.9.3 + github.com/stretchr/testify v1.8.4 github.com/thoas/go-funk v0.9.3 ) @@ -17,5 +17,5 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/teambition/rrule-go v1.7.2 // indirect golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 13f2f9e..8dc5938 100644 --- a/go.sum +++ b/go.sum @@ -11,12 +11,13 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/teambition/rrule-go v1.7.2 h1:goEajFWYydfCgavn2m/3w5U+1b3PGqPUHx/fFSVfTy0= github.com/teambition/rrule-go v1.7.2/go.mod h1:mBJ1Ht5uboJ6jexKdNUJg2NcwP8uUMNvStWXlJD3MvU= github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw= @@ -26,5 +27,6 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/outputTypes/ics.go b/pkg/outputTypes/ics.go index 68b74c8..b8a740a 100644 --- a/pkg/outputTypes/ics.go +++ b/pkg/outputTypes/ics.go @@ -6,6 +6,7 @@ import ( "io" ) +// The ICSOutputType converts the internal calendar into the standardizes ICS format type ICSOutputType struct{} func (t *ICSOutputType) Initialize(_ *argparse.Parser) error { @@ -23,3 +24,5 @@ func (t *ICSOutputType) Generate(calendar *ical.Calendar, writer io.Writer) erro func (t *ICSOutputType) GetHelp() string { return "outputs an ICS file from the processed calendar" } + +var _ BaseOutputType = &ICSOutputType{} diff --git a/pkg/outputTypes/list.go b/pkg/outputTypes/list.go index 7423317..456332d 100644 --- a/pkg/outputTypes/list.go +++ b/pkg/outputTypes/list.go @@ -7,6 +7,7 @@ import ( "io" ) +// The ListOutputType converts the internal calendar into a table format type ListOutputType struct { columns *[]string } @@ -43,3 +44,5 @@ func (t *ListOutputType) Generate(calendar *ical.Calendar, writer io.Writer) err func (t *ListOutputType) GetHelp() string { return "outputs a list of events from the processed calendar" } + +var _ BaseOutputType = &ListOutputType{} diff --git a/pkg/outputTypes/output_types.go b/pkg/outputTypes/output_types.go index 015acbe..e08b403 100644 --- a/pkg/outputTypes/output_types.go +++ b/pkg/outputTypes/output_types.go @@ -1,3 +1,5 @@ +// Package outputTypes includes all valid output types that Icarus supports. +// outputtypes use the internal processed calendar structure and format it for the output. package outputTypes import ( @@ -9,6 +11,7 @@ import ( "strings" ) +// The BaseOutputType is the basic interface for all output types type BaseOutputType interface { // Initialize can add arguments to the argument parser. Initialize(parser *argparse.Parser) error diff --git a/pkg/processors/add_alarm.go b/pkg/processors/add_alarm.go index c10e265..b52d8e4 100644 --- a/pkg/processors/add_alarm.go +++ b/pkg/processors/add_alarm.go @@ -6,6 +6,7 @@ import ( "time" ) +// The AddAlarmProcessor adds an alarm definition to all selected events type AddAlarmProcessor struct { alarmBefore *int toolbox Toolbox @@ -38,3 +39,5 @@ func (a *AddAlarmProcessor) Process(input ical.Calendar, output *ical.Calendar) } return nil } + +var _ BaseProcessor = &AddAlarmProcessor{} diff --git a/pkg/processors/add_alarm_test.go b/pkg/processors/add_alarm_test.go index 6898669..38815b8 100644 --- a/pkg/processors/add_alarm_test.go +++ b/pkg/processors/add_alarm_test.go @@ -1,9 +1,9 @@ package processors import ( + "github.com/dploeger/icarus/internal" "github.com/emersion/go-ical" "github.com/stretchr/testify/assert" - "icarus/internal" "testing" "time" ) diff --git a/pkg/processors/add_dtstamp.go b/pkg/processors/add_dtstamp.go index 5574729..4e38600 100644 --- a/pkg/processors/add_dtstamp.go +++ b/pkg/processors/add_dtstamp.go @@ -6,6 +6,7 @@ import ( "time" ) +// The AddDTStampProcessor adds a DTSTAMP field to all selected events type AddDTStampProcessor struct { timestamp *string overwrite *bool @@ -49,3 +50,5 @@ func (t *AddDTStampProcessor) Process(input ical.Calendar, output *ical.Calendar } return nil } + +var _ BaseProcessor = &AddDTStampProcessor{} diff --git a/pkg/processors/add_dtstamp_test.go b/pkg/processors/add_dtstamp_test.go index 1cfe302..338a6b5 100644 --- a/pkg/processors/add_dtstamp_test.go +++ b/pkg/processors/add_dtstamp_test.go @@ -1,9 +1,9 @@ package processors import ( + "github.com/dploeger/icarus/internal" "github.com/emersion/go-ical" "github.com/stretchr/testify/assert" - "icarus/internal" "testing" "time" ) diff --git a/pkg/processors/add_property.go b/pkg/processors/add_property.go index 6bf26c8..7a01e9c 100644 --- a/pkg/processors/add_property.go +++ b/pkg/processors/add_property.go @@ -6,6 +6,7 @@ import ( "strings" ) +// The AddPropertyProcessor adds an ICS property to each selected event type AddPropertyProcessor struct { propertyName *string propertyValue *string @@ -50,3 +51,5 @@ func (a *AddPropertyProcessor) Process(input ical.Calendar, output *ical.Calenda } return nil } + +var _ BaseProcessor = &AddPropertyProcessor{} diff --git a/pkg/processors/add_property_test.go b/pkg/processors/add_property_test.go index 1ee3f24..a0074d1 100644 --- a/pkg/processors/add_property_test.go +++ b/pkg/processors/add_property_test.go @@ -1,9 +1,9 @@ package processors import ( + "github.com/dploeger/icarus/internal" "github.com/emersion/go-ical" "github.com/stretchr/testify/assert" - "icarus/internal" "testing" ) diff --git a/pkg/processors/convert_all_day.go b/pkg/processors/convert_all_day.go index c2f3ae6..68a9437 100644 --- a/pkg/processors/convert_all_day.go +++ b/pkg/processors/convert_all_day.go @@ -11,6 +11,7 @@ import ( "time" ) +// The ConvertAllDayProcessor converts all-day events to timed events or vice versa type ConvertAllDayProcessor struct { toolbox Toolbox targetAllDay *bool @@ -156,3 +157,5 @@ func (c *ConvertAllDayProcessor) getStartAndEndDuration() (time.Duration, time.D } return startDuration, endDuration, nil } + +var _ BaseProcessor = &ConvertAllDayProcessor{} diff --git a/pkg/processors/convert_all_day_test.go b/pkg/processors/convert_all_day_test.go index c0031d9..75a1cd5 100644 --- a/pkg/processors/convert_all_day_test.go +++ b/pkg/processors/convert_all_day_test.go @@ -1,9 +1,9 @@ package processors import ( + "github.com/dploeger/icarus/internal" "github.com/emersion/go-ical" "github.com/stretchr/testify/assert" - "icarus/internal" "testing" "time" ) diff --git a/pkg/processors/delete_property.go b/pkg/processors/delete_property.go index 617d013..5c042cf 100644 --- a/pkg/processors/delete_property.go +++ b/pkg/processors/delete_property.go @@ -6,6 +6,7 @@ import ( "strings" ) +// The DeletePropertyProcessor deletes an ICS property from all selected events type DeletePropertyProcessor struct { propertyName *string toolbox Toolbox @@ -35,3 +36,5 @@ func (d *DeletePropertyProcessor) Process(input ical.Calendar, output *ical.Cale } return nil } + +var _ BaseProcessor = &DeletePropertyProcessor{} diff --git a/pkg/processors/delete_property_test.go b/pkg/processors/delete_property_test.go index e3d3389..c06e31e 100644 --- a/pkg/processors/delete_property_test.go +++ b/pkg/processors/delete_property_test.go @@ -1,9 +1,9 @@ package processors import ( + "github.com/dploeger/icarus/internal" "github.com/emersion/go-ical" "github.com/stretchr/testify/assert" - "icarus/internal" "testing" ) diff --git a/pkg/processors/filter.go b/pkg/processors/filter.go index 1b2a366..9b3092c 100644 --- a/pkg/processors/filter.go +++ b/pkg/processors/filter.go @@ -5,6 +5,7 @@ import ( "github.com/emersion/go-ical" ) +// The FilterProcessor filters the calendar for selected events type FilterProcessor struct { toolbox Toolbox inverse *bool @@ -33,3 +34,5 @@ func (f *FilterProcessor) Process(inputCalendar ical.Calendar, outputCalendar *i func (f *FilterProcessor) SetToolbox(toolbox Toolbox) { f.toolbox = toolbox } + +var _ BaseProcessor = &FilterProcessor{} diff --git a/pkg/processors/filter_test.go b/pkg/processors/filter_test.go index ae0db82..89d438e 100644 --- a/pkg/processors/filter_test.go +++ b/pkg/processors/filter_test.go @@ -1,10 +1,10 @@ package processors import ( + "github.com/dploeger/icarus/internal" "github.com/emersion/go-ical" "github.com/stretchr/testify/assert" _ "github.com/stretchr/testify/assert" - "icarus/internal" "regexp" "testing" ) diff --git a/pkg/processors/print.go b/pkg/processors/print.go index f59c7fd..f5e13e0 100644 --- a/pkg/processors/print.go +++ b/pkg/processors/print.go @@ -5,6 +5,7 @@ import ( "github.com/emersion/go-ical" ) +// The PrintProcessor simply outputs the input calendar type PrintProcessor struct { toolbox Toolbox } @@ -24,3 +25,5 @@ func (f *PrintProcessor) Process(inputCalendar ical.Calendar, outputCalendar *ic func (f *PrintProcessor) SetToolbox(toolbox Toolbox) { f.toolbox = toolbox } + +var _ BaseProcessor = &PrintProcessor{} diff --git a/pkg/processors/processors.go b/pkg/processors/processors.go index 04ff0c2..81fb9fb 100644 --- a/pkg/processors/processors.go +++ b/pkg/processors/processors.go @@ -1,3 +1,7 @@ +// Package processors includes all calendar processors available in Icarus. +// +// Icarus parses the incoming calendar data, hands it over to the processor to process data in it and +// formats the resulting data using an output type package processors import ( @@ -5,6 +9,7 @@ import ( "github.com/emersion/go-ical" ) +// The BaseProcessor is the interface for all Icarus processors type BaseProcessor interface { // Initialize creates a new subcommand for the argparse parser. Initialize(parser *argparse.Parser) (*argparse.Command, error) diff --git a/pkg/processors/toolbox.go b/pkg/processors/toolbox.go index a5bfdbb..92cb71f 100644 --- a/pkg/processors/toolbox.go +++ b/pkg/processors/toolbox.go @@ -1,7 +1,5 @@ package processors -// a toolbox of common functions - import ( "github.com/emersion/go-ical" "github.com/sirupsen/logrus" @@ -9,6 +7,7 @@ import ( "time" ) +// A Toolbox of common functions type Toolbox struct { // TextSelectorPattern is the user specified regexp pattern to select events by TextSelectorPattern *regexp.Regexp diff --git a/pkg/processors/toolbox_test.go b/pkg/processors/toolbox_test.go index f118844..46c38cb 100644 --- a/pkg/processors/toolbox_test.go +++ b/pkg/processors/toolbox_test.go @@ -1,9 +1,9 @@ package processors import ( + "github.com/dploeger/icarus/internal" "github.com/emersion/go-ical" "github.com/stretchr/testify/assert" - "icarus/internal" "regexp" "testing" "time"