diff --git a/cmd/about.go b/cmd/about.go index a912da2..7afa4ba 100644 --- a/cmd/about.go +++ b/cmd/about.go @@ -11,7 +11,7 @@ type aboutCommand struct { buildHash string } -func NewAboutCommand(version string, buildHash string) AboutCommand { +func NewAboutCommand(version, buildHash string) AboutCommand { return &aboutCommand{ version: version, buildHash: buildHash, diff --git a/cmd/edit.go b/cmd/edit.go index c808da6..a359b36 100644 --- a/cmd/edit.go +++ b/cmd/edit.go @@ -22,7 +22,6 @@ type editCommand struct { func NewEditCommand(ctx stoic.Context, value string) EditCommand { date, err := naturaldate.Parse(value, time.Now()) - if err != nil { fmt.Println("Error parsing date:", err) os.Exit(1) @@ -42,7 +41,6 @@ func (e *editCommand) Date() time.Time { func (e *editCommand) Run() { entry := stoic.NewEntry(e.ctx, e.date) err := e.ctx.OpenInEditor(entry) - if err != nil { fmt.Println("Error running program:", err) os.Exit(1) diff --git a/cmd/list.go b/cmd/list.go index 1c21675..20443c0 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -107,7 +107,6 @@ func (m model) View() string { } func OpenFileInEditor(filepath string, ctx stoic.Context) error { - cmd := exec.Command(ctx.Editor(), filepath) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout diff --git a/cmd/quote.go b/cmd/quote.go index 5f14b66..95de271 100644 --- a/cmd/quote.go +++ b/cmd/quote.go @@ -30,7 +30,7 @@ var ( BorderRight(true). BorderBottom(true) - authoredBy = lipgloss.NewStyle().SetString("©"). + authoredBy = lipgloss.NewStyle().SetString("—"). PaddingRight(1). Foreground(foreground). String() diff --git a/internal/context.go b/internal/context.go index f9315bd..8c8af21 100644 --- a/internal/context.go +++ b/internal/context.go @@ -11,9 +11,11 @@ import ( homedir "github.com/mitchellh/go-homedir" ) -const DEFAULT_EDITOR = "nano" -const DEFAULT_DIRECTORY = "~/Journal/" -const DEFAULT_EXTENSION = "md" +const ( + DEFAULT_EDITOR = "nano" + DEFAULT_DIRECTORY = "~/Journal/" + DEFAULT_EXTENSION = "md" +) type Context interface { Directory() string @@ -31,7 +33,7 @@ type context struct { template string } -func NewContext(homeDir string, fileExtension string, editor string, template string) Context { +func NewContext(homeDir, fileExtension, editor, template string) Context { directory := expandDir(homeDir) if fileExtension == "" { @@ -75,7 +77,7 @@ func (ctx *context) OpenInEditor(entry Entry) error { return cmd.Run() } -func createFileFromTemplate(filename string, template_path string) error { +func createFileFromTemplate(filename, template_path string) error { file, err := os.Create(filename) if err != nil { return err @@ -148,8 +150,7 @@ func (ctx context) Files() []string { func createDirectoryIfMissing(dir string) error { if _, err := os.Stat(dir); os.IsNotExist(err) { - err := os.MkdirAll(dir, 0755) - + err := os.MkdirAll(dir, 0o755) if err != nil { return err } diff --git a/main.go b/main.go index 700b606..edbdcf8 100644 --- a/main.go +++ b/main.go @@ -10,8 +10,10 @@ import ( stoic "github.com/skatkov/stoic/internal" ) -var BinaryVersion string // Set via build flag -var BinaryBuildHash string // Set via build flag +var ( + BinaryVersion string // Set via build flag + BinaryBuildHash string // Set via build flag +) func main() { ctx := stoic.NewContext( @@ -38,7 +40,6 @@ func main() { cmd.NewQuoteCommand().Run() default: err := ctx.OpenInEditor(stoic.NewEntry(ctx, time.Now())) - if err != nil { fmt.Println(err) }