Skip to content

Commit

Permalink
build: move the main file into the project root
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed May 21, 2023
1 parent 133a6c7 commit b1a6dc1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ with [bubble tea](https://github.com/charmbracelet/bubbletea)
Installing is extremely easy with `go install`

```
go install github.com/TypicalAM/goread/cmd/goread@latest
go install github.com/TypicalAM/goread@latest
```

Which produces a `goread` executable
Expand Down
8 changes: 3 additions & 5 deletions cmd/goread/main.go → cmd/goread/goread.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package goread

import (
"fmt"
Expand Down Expand Up @@ -52,13 +52,15 @@ func init() {
rootCmd.Flags().IntVarP(&opts.cacheDuration, "cache_duration", "d", 0, "The duration of the cache in hours")
}

// Execute executes the commands
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "There has been an error executing the commands: '%s'", err)
os.Exit(1)
}
}

// Run runs the program
func Run() error {
// Initialize the colorscheme
colors := colorscheme.New(opts.colorschemePath)
Expand Down Expand Up @@ -119,7 +121,3 @@ func Run() error {
// Close the config
return cfg.Close()
}

func main() {
Execute()
}
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/TypicalAM/goread/cmd/goread"

func main() {
goread.Execute()
}

0 comments on commit b1a6dc1

Please sign in to comment.