Skip to content

Commit

Permalink
Move to yaml for config
Browse files Browse the repository at this point in the history
  • Loading branch information
PuruVJ committed Jan 17, 2022
1 parent e429353 commit 62f61fd
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 128 deletions.
71 changes: 71 additions & 0 deletions auto-class-launcher-timetable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
DBMS 💾:
link: 'https://meet.google.com/bvh-ixke-qxj?authuser=2'
times:
- day: mon
time: 9:00
- day: wed
time: 15:00
- day: thu
time: 9:00
- day: fri
time: 9:00

DBMS Practice 💾:
link: https://meet.google.com/bvh-ixke-qxj?authuser=2
times:
- day: mon
time: 14:00

Probability 🤥:
link: https://meet.google.com/vmu-krpk-cvr?authuser=2
times:
- day: mon
time: 11:00
- day: tue
time: 10:00
- day: thu
time: 13:00
- day: fri
time: 14:00

TOC - Youtubeeeeee 🎥:
link: https://www.youtube.com/channel/UCMcX0_nLyJkJ-C4bVvrEcmA
times:
- day: mon
time: 10:00
- day: tue
time: 9:00
- day: wed
time: 13:00
- day: fri
time: 11:00

TOC Practical:
link: https://meet.google.com/fmv-yypx-ofe?authuser=2
times:
- day: wed
time: 14:00

COA 😭:
link: https://meet.google.com/vuj-ccot-cxz?authuser=2
times:
- day: mon
time: 13:00
- day: tue
time: 11:00
- day: thu
time: 11:00
- day: fri
time: 13:00

COA Practise:
links: https://meet.google.com/vuj-ccot-cxz?authuser=2
times:
- day: tue
time: 14:00

SPD 👩‍🦼:
links: https://teams.microsoft.com/_
times:
- day: thu
time: 15:00
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ require (
)

require (
github.com/ghodss/yaml v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
Expand All @@ -24,3 +26,6 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+R
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY=
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
11 changes: 5 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
_ "embed"
"encoding/json"
"fmt"
"net/url"
"os"
Expand All @@ -11,6 +10,7 @@ import (
"time"

"github.com/fatih/color"
"github.com/ghodss/yaml"
"github.com/skratchdot/open-golang/open"
)

Expand All @@ -34,7 +34,7 @@ type ClassToday struct {

var todaysClassLaunched map[string]bool

//go:embed sample.json
//go:embed sample.yaml
var sampleConfigStr []byte

func openClassLink(config ClassConfig) {
Expand Down Expand Up @@ -106,16 +106,15 @@ func openClassLink(config ClassConfig) {
}

func main() {

CONFIG_PATH := "./auto-class-launcher-timetable.json"
CONFIG_PATH := "./auto-class-launcher-timetable.yaml"

var config ClassConfig

// Now check if file exists
if data, err := os.ReadFile(CONFIG_PATH); err == nil {
json.Unmarshal(data, &config)
yaml.Unmarshal(data, &config)
} else if os.IsNotExist(err) {
json.Unmarshal([]byte(sampleConfigStr), &config)
yaml.Unmarshal([]byte(sampleConfigStr), &config)

if os.WriteFile(CONFIG_PATH, sampleConfigStr, 0666) != nil {
fmt.Println("Unable to create timetable on disk")
Expand Down
122 changes: 0 additions & 122 deletions sample.json

This file was deleted.

71 changes: 71 additions & 0 deletions sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
DBMS 💾:
link: 'https://meet.google.com/bvh-ixke-qxj?authuser=2'
times:
- day: mon
time: 9:00
- day: wed
time: 15:00
- day: thu
time: 9:00
- day: fri
time: 9:00

DBMS Practice 💾:
link: https://meet.google.com/bvh-ixke-qxj?authuser=2
times:
- day: mon
time: 14:00

Probability 🤥:
link: https://meet.google.com/vmu-krpk-cvr?authuser=2
times:
- day: mon
time: 11:00
- day: tue
time: 10:00
- day: thu
time: 13:00
- day: fri
time: 14:00

TOC - Youtubeeeeee 🎥:
link: https://www.youtube.com/channel/UCMcX0_nLyJkJ-C4bVvrEcmA
times:
- day: mon
time: 10:00
- day: tue
time: 9:00
- day: wed
time: 13:00
- day: fri
time: 11:00

TOC Practical:
link: https://meet.google.com/fmv-yypx-ofe?authuser=2
times:
- day: wed
time: 14:00

COA 😭:
link: https://meet.google.com/vuj-ccot-cxz?authuser=2
times:
- day: mon
time: 13:00
- day: tue
time: 11:00
- day: thu
time: 11:00
- day: fri
time: 13:00

COA Practise:
links: https://meet.google.com/vuj-ccot-cxz?authuser=2
times:
- day: tue
time: 14:00

SPD 👩‍🦼:
links: https://teams.microsoft.com/_
times:
- day: thu
time: 15:00

1 comment on commit 62f61fd

@vercel
Copy link

@vercel vercel bot commented on 62f61fd Jan 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.