Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tmacro committed May 18, 2024
1 parent 95b97a9 commit b015c82
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,4 @@ dmypy.json
bin/

dist/
.fleet/
5 changes: 1 addition & 4 deletions pkg/cli/note/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ func (c *CreateCommand) Run(ctx *cli.Context) error {
return err
}

filename, err := utils.FormatDateFile(ctx.Config.Notes.Directory, date, ctx.Config.Notes.Extension)
if err != nil {
return err
}
filename := utils.FormatDateFile(ctx.Config.Notes.Directory, date, ctx.Config.Notes.Extension)

_, err = os.Stat(filename)
if err == nil {
Expand Down
6 changes: 1 addition & 5 deletions pkg/cli/note/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ func (c *ShowCommand) Run(ctx *cli.Context) error {
return err
}

filename, err := utils.FormatDateFile(ctx.Config.Notes.Directory, date, ctx.Config.Notes.Extension)
if err != nil {
return err
}

filename := utils.FormatDateFile(ctx.Config.Notes.Directory, date, ctx.Config.Notes.Extension)
fmt.Println(filename)
return nil
}
5 changes: 1 addition & 4 deletions pkg/cli/note/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ func (c *ViewCommand) Run(ctx *cli.Context) error {
return err
}

filename, err := utils.FormatDateFile(ctx.Config.Notes.Directory, date, ctx.Config.Notes.Extension)
if err != nil {
return err
}
filename := utils.FormatDateFile(ctx.Config.Notes.Directory, date, ctx.Config.Notes.Extension)

tmpl, err := template.New("view").Parse(ctx.Config.Notes.Viewer)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ func getHomeDir(name string) (string, error) {
return dir, nil
}

func FormatDateDir(parent, date string) (string, error) {
return filepath.Join(parent, date), nil
func FormatDateDir(parent, date string) string {
return filepath.Join(parent, date)
}

func FormatDateFile(parent, date, extension string) (string, error) {
return filepath.Join(parent, date+extension), nil
func FormatDateFile(parent, date, extension string) string {
return filepath.Join(parent, date+extension)
}

0 comments on commit b015c82

Please sign in to comment.