Skip to content

Commit

Permalink
Add stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jafarlihi committed Nov 19, 2022
1 parent 6cde34f commit 2fca7f5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"errors"
"os"
"strings"

"github.com/go-ini/ini"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -53,6 +54,10 @@ func LoadConfig() {

Config = Configuration{}
Config.FeedDirectory = cfg.Section("settings").Key("feed_directory").String()
if strings.HasPrefix(Config.FeedDirectory, "~") {
Config.FeedDirectory = homePath + Config.FeedDirectory[1:]
}
os.MkdirAll(Config.FeedDirectory, 0744)
Config.Viewer = cfg.Section("settings").Key("viewer").String()
for _, key := range cfg.Section("feeds").Keys() {
Config.Feeds = append(Config.Feeds, Feed{key.String(), cfg.Section("feeds").Key(key.String()).String()})
Expand Down
20 changes: 18 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func main() {
cmd := exec.Command(editor, homePath+"/.config/rssnix/config.ini")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
err = cmd.Run()
return err
return cmd.Run()
},
},
{
Expand All @@ -49,6 +48,23 @@ func main() {
return nil
},
},
{
Name: "open",
Aliases: []string{"o"},
Usage: "open given feed's directory or root feeds directory if no argument is given",
Action: func(cCtx *cli.Context) error {
var path string
if cCtx.Args().Len() == 0 {
path = Config.FeedDirectory
} else {
path = Config.FeedDirectory + "/" + cCtx.Args().Get(0)
}
cmd := exec.Command(Config.Viewer, path)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
return cmd.Run()
},
},
},
}

Expand Down

0 comments on commit 2fca7f5

Please sign in to comment.