Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minor go file format changes #32

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
BorderRight(true).
BorderBottom(true)

authoredBy = lipgloss.NewStyle().SetString("©").
authoredBy = lipgloss.NewStyle().SetString("").
philoserf marked this conversation as resolved.
Show resolved Hide resolved
PaddingRight(1).
Foreground(foreground).
String()
Expand Down
15 changes: 8 additions & 7 deletions internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 == "" {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -38,7 +40,6 @@ func main() {
cmd.NewQuoteCommand().Run()
default:
err := ctx.OpenInEditor(stoic.NewEntry(ctx, time.Now()))

if err != nil {
fmt.Println(err)
}
Expand Down