Skip to content

Commit

Permalink
Labels available
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Horn committed May 24, 2018
1 parent 68b642d commit 2898e39
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Usage: `ical2org [-d=<duplicates>] [-o=output] [-a=append]
[--inactive] [--active]
[--deadline] [--scheduled]
[--repeats] [-dupinput] [-count] [-after duration | date]
[--label label]
input files`

The input files can be URLs ("http://...."), local files, or stdin. If the filename given is "-" then stdin is read.
Expand Down Expand Up @@ -52,6 +53,13 @@ Example output:
```

Other options:
* `label`, provides a convert label that can be specified on the command line and which will be placed in ICALCONTENTS. This can be useful for debugging and tracing.
* `Repeats`, see below
* `counts`, sends to stdout a count of events converted. Should only be used when -o or -a are specified. This is useful when running fetch and convert automatically at intervals.
* `dupinput`, see below
* `after`, see below

### Installation

To install this package make sure that you have the go toolchain installed https://golang.org/doc/code.html.
Expand Down
7 changes: 7 additions & 0 deletions ical2org.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type args struct {
appfile string
outfile string
afterfile string
label string
dupflag bool
sched bool
active bool
Expand All @@ -35,12 +36,14 @@ func main() {
var appPtr *string
var outPtr *string
var afterPtr *string
var labelPtr *string

// define flags
dupfilePtr = flag.String("d", "", "Filename for duplicate removal")
appPtr = flag.String("a", "", "Filename to append new events")
outPtr = flag.String("o", "", "Filename for event output, default stdout")
afterPtr = flag.String("after", "", "Only use events at and after this date")
labelPtr = flag.String("label", "", "Label word in drawer to identify conversion")
flag.BoolVar(&a.sched, "scheduled", false, "Event time should be scheduled")
flag.BoolVar(&a.dead, "deadline", false, "Event time should be deadline")
flag.BoolVar(&a.active, "active", true, "Headline timestamp should be active")
Expand All @@ -56,6 +59,7 @@ func main() {
a.appfile = *appPtr
a.outfile = *outPtr
a.afterfile = *afterPtr
a.label = *labelPtr
a.args = flag.Args()

process(a)
Expand Down Expand Up @@ -187,6 +191,9 @@ func process(a args) {
// Print drawer contents
fmt.Fprintln(f, " :ICALCONTENTS:")
fmt.Fprintf(f, " :ORGUID: %s\n", event.GetID())
if a.label != "" {
fmt.Fprintf(f, " :CONVERTLABEL: %s\n", a.label)
}
fmt.Fprintf(f, " :ORIGINAL-UID: %s\n", event.GetImportedID())
fmt.Fprintf(f, " :DTSTART: %s\n", event.GetStart().Format("2006-01-02 15:04"))
fmt.Fprintf(f, " :DTEND: %s\n", event.GetEnd().Format("2006-01-02 15:04"))
Expand Down
12 changes: 9 additions & 3 deletions ical2org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import (
//"github.com/davecgh/go-spew/spew"
)

//func TestMain(t *testing.T) {
//}

func TestMultiple(t *testing.T) {
a := args{outfile: "tests/xx91596.org", count: true, args: []string{"tests/xx91596.ics", "tests/test-vcal-3.vcs", "tests/wg-29.ics"}}

Expand Down Expand Up @@ -119,6 +116,15 @@ func TestAfterDuration(t *testing.T) {
}
}

func TestLabel(t *testing.T) {
a := args{outfile: "tests/xx91596.org", label: "test-label", args: []string{"tests/xx91596.ics"}}

process(a)
// compare with org-inactive
if compareFiles(a.outfile, "tests/xx91596.org-labeled", t) == false {
t.Fail()
}
}
//
// file comparison function. This assumes files are small and memory is large.
// It reads the whole files into memory and then compares.
Expand Down
52 changes: 52 additions & 0 deletions tests/xx91596.org-labeled
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
* DECISION MEETING: ITI Planning Monthly Call (11am CT, 12pm ET, 6pm CET) Host key: 426290 <2027-10-19 Tue 11:00>
:ICALCONTENTS:
:ORGUID: 1e23c027675290d3a25f3f8441bd91b2
:CONVERTLABEL: test-label
:ORIGINAL-UID: 040000008200E00074C5B7101A82E00800000000C0DE4F324F47D301000000000000000010000000ED14C4A947673341969029C8BE8EDA02
:DTSTART: 2027-10-19 11:00
:DTEND: 2027-10-19 12:30
:DTSTAMP: 2017-10-17 19:04
:ORGANIZER: <nil>
:TZIDS: TZID="Central Standard Time":
:RRULE:
:END:
** Description

Jeremiah Myers invites you to an online meeting using WebEx.

Meeting Number: 925 553 694
Meeting Password: Meeting1

-------------------------------------------------------
To join this meeting
-------------------------------------------------------
1. Go to https://himss.webex.com/himss/j.php?MTID=m3d54120cb272c8086d3f02ceec040c2c
2. Enter the meeting password: Meeting1
3. Click "Join Now".
4. Follow the instructions that appear on your screen to join the teleconference.

-------------------------------------------------------
To join the meeting on iPhone
-------------------------------------------------------
Go to wbx://himss.webex.com/himss?MK=925553694&amp\;MTGTK=SDJTSwAAAARbAc6CcpGQ6NUfT1L93Znv928awPy2o6Rd5peFVFPyjQ2&amp\;r2sec=1

Don&apos\;t have the iPhone WebEx application yet?
Go to http://itunes.apple.com/app/cisco-webex-meetings/id298844386
IMPORTANT NOTICE: This WebEx service includes a feature that allows audio and any documents and other materials exchanged or viewed during the session to be recorded. By joining this session, you automatically consent to such recordings. If you do not consent to the recording, discuss your concerns with the meeting host prior to the start of the recording or do not join the session. Please note that any such recordings may be subject to discovery in the event of litigation.

-------------------------------------------------------
To only join the teleconference
-------------------------------------------------------
To receive a call back, provide your phone number when you join the meeting, or call the number below and enter the access code.
Call-in toll-free number (US/Canada): 1-866-469-3239
Call-in toll number (US/Canada): 1-650-429-3300

Access code:925 553 694
Global call-in numbers: https://himss.webex.com/himss/globalcallin.php?serviceType=MC&ED=554885172&tollFree=1
Toll-free dialing restrictions: https://www.webex.com/pdf/tollfree_restrictions.pdf





** Location https//himss.webex.com/himss/j.php?MTID=m3d54120cb272c8086d3f02ceec040c2c

0 comments on commit 2898e39

Please sign in to comment.