Skip to content

Commit

Permalink
feat: refresh without tui interval functionality (#102)
Browse files Browse the repository at this point in the history
add refresh command to update database manually
add config command to display config 

relates #102
  • Loading branch information
coolsloth55 authored Dec 16, 2024
1 parent bd841d9 commit 0087188
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ $ curl -L https://github.com/guyfedwards/nom/releases/download/v2.1.4/nom_2.1.4_
```sh
$ nom # start TUI
$ nom list -n 20 # list feed items in $PAGER, optionally show more
$ nom add <feed_url>
$ nom add <feed_url>
$ nom refresh # refresh feed(s) without opening TUI
$ nom config # shows nom config
$ nom --feed <feed_url> # preview feed without adding to config
```

Expand Down
4 changes: 4 additions & 0 deletions cmd/nom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func run(args []string, opts Options) error {
switch args[0] {
case "list":
return cmds.List(opts.Number)
case "refresh":
return cmds.Refresh()
case "config":
return cmds.ShowConfig()
case "add":
if len(args) != 2 {
return ErrNotEnoughArgs
Expand Down
17 changes: 17 additions & 0 deletions internal/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/glamour/ansi"
"gopkg.in/yaml.v3"

"github.com/guyfedwards/nom/v2/internal/config"
"github.com/guyfedwards/nom/v2/internal/rss"
Expand Down Expand Up @@ -150,6 +151,22 @@ func (c Commands) Add(url string) error {
return nil
}

func (c Commands) Refresh() error {
_, _, err := c.fetchAllFeeds()
if err != nil {
return fmt.Errorf("commands Refresh: %w", err)
}
return nil
}
func (c Commands) ShowConfig() error {
yaml, err := yaml.Marshal(&c.config)
if err != nil {
return fmt.Errorf("commands Config: %w", err)
}
fmt.Print(string(yaml))
return nil
}

type FetchResultError struct {
res rss.RSS
err error
Expand Down

0 comments on commit 0087188

Please sign in to comment.