-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
132 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,41 @@ | ||
module github.com/notnmeyer/daylog-cli | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/adrg/xdg v0.4.0 | ||
github.com/charmbracelet/glamour v0.6.0 | ||
github.com/markusmobius/go-dateparser v1.2.1 | ||
github.com/spf13/cobra v1.7.0 | ||
) | ||
|
||
require ( | ||
github.com/alecthomas/chroma v0.10.0 // indirect | ||
github.com/aymanbagabas/go-osc52 v1.0.3 // indirect | ||
github.com/aymerick/douceur v0.2.0 // indirect | ||
github.com/dlclark/regexp2 v1.4.0 // indirect | ||
github.com/elliotchance/pie/v2 v2.7.0 // indirect | ||
github.com/gorilla/css v1.0.0 // indirect | ||
github.com/hablullah/go-hijri v1.0.2 // indirect | ||
github.com/hablullah/go-juliandays v1.0.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/jalaali/go-jalaali v0.0.0-20210801064154-80525e88d958 // indirect | ||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect | ||
github.com/magefile/mage v1.14.0 // indirect | ||
github.com/mattn/go-isatty v0.0.16 // indirect | ||
github.com/mattn/go-runewidth v0.0.14 // indirect | ||
github.com/microcosm-cc/bluemonday v1.0.21 // indirect | ||
github.com/muesli/reflow v0.3.0 // indirect | ||
github.com/muesli/termenv v0.13.0 // indirect | ||
github.com/olekukonko/tablewriter v0.0.5 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/tetratelabs/wazero v1.2.1 // indirect | ||
github.com/wasilibs/go-re2 v1.3.0 // indirect | ||
github.com/yuin/goldmark v1.5.2 // indirect | ||
github.com/yuin/goldmark-emoji v1.0.1 // indirect | ||
golang.org/x/exp v0.0.0-20220321173239-a90fa8a75705 // indirect | ||
golang.org/x/net v0.0.0-20221002022538-bcab6841153b // indirect | ||
golang.org/x/sys v0.5.0 // indirect | ||
golang.org/x/text v0.10.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package outputFormatter | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/charmbracelet/glamour" | ||
) | ||
|
||
var MarkdownFormats = []string{ | ||
"markdown", "md", | ||
} | ||
|
||
var OutputFormats = append( | ||
MarkdownFormats, | ||
"text", | ||
) | ||
|
||
func Format(format, content string) (string, error) { | ||
if !contains(OutputFormats, format) { | ||
return "", fmt.Errorf("output must be one of %v\n", OutputFormats) | ||
} | ||
|
||
switch format { | ||
case "markdown", "md": | ||
renderer, _ := glamour.NewTermRenderer( | ||
glamour.WithAutoStyle(), | ||
) | ||
|
||
var err error | ||
content, err = renderer.Render(content) | ||
if err != nil { | ||
return "", err | ||
} | ||
} | ||
|
||
return content, nil | ||
} | ||
|
||
func isMarkdownFormat() { | ||
|
||
} | ||
|
||
func contains(list []string, item string) bool { | ||
for _, val := range list { | ||
if val == item { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
pkgs.mkShell { | ||
packages = with pkgs; [ | ||
delve | ||
go | ||
go_1_21 | ||
gopls | ||
goreleaser | ||
]; | ||
|