Skip to content
Permalink
Browse files

First version of CLI that can set a status

  • Loading branch information...
kiriappeee committed Mar 25, 2018
1 parent be1f7e6 commit 51a7f5b05e223b58a786268021defa9d25851e9f
Showing with 48 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +8 −2 Gopkg.lock
  3. +39 −0 cli.go
@@ -1 +1,2 @@
vendor/
sampleconfig

Some generated files are not rendered by default. Learn more.

39 cli.go
@@ -0,0 +1,39 @@
package main

import (
"os"
"log"

"github.com/urfave/cli"
"github.com/kiriappeee/slack-status-updater-core"
)

func main(){
app := cli.NewApp()
slackToken := os.Getenv("SLACKPERSONALTOKEN")
fileToReadStatusesFrom := os.Getenv("HOME") + "/.config/ssucli/statuses.yaml"
app.Action = func(c *cli.Context) error {
statusName := c.Args().Get(0)
statusList, err := getStatusesFromFile(fileToReadStatusesFrom)
if err != nil {
log.Fatal(err)
}
statusToSet, err := pickStatusFromList(statusName, statusList)
if err != nil {
log.Fatal(err)
}
res, err := statusToSet.SetMyStatus(ssucore.UpdateStatusViaSDK, slackToken)
if res != "" {
log.Printf(res)
}

if err != nil {
log.Fatal(err)
}
return nil
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}

0 comments on commit 51a7f5b

Please sign in to comment.
You can’t perform that action at this time.