fix: correct build errors and clean up code
This commit is contained in:
parent
c39a2f31e6
commit
0b2ec9ce15
4
Makefile
4
Makefile
|
@ -11,8 +11,8 @@ verbose: goimports vet
|
||||||
GO111MODULE=off go install -v -x \
|
GO111MODULE=off go install -v -x \
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
build: goimports vet
|
build: goimports
|
||||||
GO111MODULE=off go build -v -x \
|
GO111MODULE=off go build \
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
install: goimports vet
|
install: goimports vet
|
||||||
|
|
10
add.go
10
add.go
|
@ -28,10 +28,10 @@ func addFile(filename string) (*chatpb.Chats, error) {
|
||||||
logDir := filepath.Dir(filename)
|
logDir := filepath.Dir(filename)
|
||||||
|
|
||||||
// Iterate through the structure to inline all external content.
|
// Iterate through the structure to inline all external content.
|
||||||
for _, chat := range logData.GetChats() {
|
for _, chat := range logData.Chats {
|
||||||
for _, entry := range chat.GetEntries() {
|
for _, entry := range chat.Entries {
|
||||||
// Inline main content from ContentFile
|
// Inline main content from ContentFile
|
||||||
if contentFile := entry.GetContentFile(); contentFile != "" {
|
if contentFile := entry.ContentFile; contentFile != "" {
|
||||||
contentPath := filepath.Join(logDir, contentFile)
|
contentPath := filepath.Join(logDir, contentFile)
|
||||||
contentBytes, err := os.ReadFile(contentPath)
|
contentBytes, err := os.ReadFile(contentPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -42,9 +42,9 @@ func addFile(filename string) (*chatpb.Chats, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inline snippet content from snippet files
|
// Inline snippet content from snippet files
|
||||||
if snippets := entry.GetSnippets(); snippets != nil {
|
if snippets := entry.Snippets; snippets != nil {
|
||||||
for _, snippet := range snippets {
|
for _, snippet := range snippets {
|
||||||
if snippetFile := snippet.GetFilename(); snippetFile != "" {
|
if snippetFile := snippet.Filename; snippetFile != "" {
|
||||||
snippetPath := filepath.Join(logDir, snippetFile)
|
snippetPath := filepath.Join(logDir, snippetFile)
|
||||||
contentBytes, err := os.ReadFile(snippetPath)
|
contentBytes, err := os.ReadFile(snippetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
24
argv.go
24
argv.go
|
@ -10,19 +10,19 @@ package main
|
||||||
var argv args
|
var argv args
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
Add string `arg:"--add" help:"add a new chat"`
|
Add string `arg:"--add" help:"add a new chat"`
|
||||||
Format *EmptyCmd `arg:"subcommand:format" help:"add a conversation"`
|
Format *EmptyCmd `arg:"subcommand:format" help:"add a conversation"`
|
||||||
Playback *PlaybackCmd `arg:"subcommand:playback" help:"dump your prior conversations to the terminal'"`
|
Playback *PlaybackCmd `arg:"subcommand:playback" help:"dump your prior conversations to the terminal'"`
|
||||||
Output string `arg:"--output" help:"should get a string from regex-cli"`
|
Output string `arg:"--output" help:"should get a string from regex-cli"`
|
||||||
Input string `arg:"--input" help:"should get a string from regex-cli"`
|
Input string `arg:"--input" help:"should get a string from regex-cli"`
|
||||||
ImportFile string `arg:"--import" help:"import a file from regex-cli"`
|
ImportFile string `arg:"--import" help:"import a file from regex-cli"`
|
||||||
Stats []string `arg:"--stats" help:"add stats to a chat"`
|
Stats []string `arg:"--stats" help:"add stats to a chat"`
|
||||||
NewChat []string `arg:"--new-chat" help:"create a new chat"`
|
NewChat []string `arg:"--new-chat" help:"create a new chat"`
|
||||||
GetNextAutoTopic bool `arg:"--get-next-auto-topic" help:"get the next auto topic name"`
|
GetNextAutoTopic bool `arg:"--get-next-auto-topic" help:"get the next auto topic name"`
|
||||||
Force bool `arg:"--force" help:"try to strong arm things"`
|
Force bool `arg:"--force" help:"try to strong arm things"`
|
||||||
Verbose bool `arg:"--verbose" help:"show more output"`
|
Verbose bool `arg:"--verbose" help:"show more output"`
|
||||||
Bash bool `arg:"--bash" help:"generate bash completion"`
|
Bash bool `arg:"--bash" help:"generate bash completion"`
|
||||||
BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"`
|
BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmptyCmd struct {
|
type EmptyCmd struct {
|
||||||
|
|
|
@ -95,7 +95,7 @@ func listEntries(chat *chatpb.Chat) {
|
||||||
contentPreview = strings.ReplaceAll(contentPreview, "\n", " ")
|
contentPreview = strings.ReplaceAll(contentPreview, "\n", " ")
|
||||||
|
|
||||||
authorAndTime := fmt.Sprintf("[%s] (%s)", author, formattedTime)
|
authorAndTime := fmt.Sprintf("[%s] (%s)", author, formattedTime)
|
||||||
|
|
||||||
availableWidth := width - maxAuthorAndTimeLen - 1 // -1 for a space
|
availableWidth := width - maxAuthorAndTimeLen - 1 // -1 for a space
|
||||||
if len(contentPreview) > availableWidth {
|
if len(contentPreview) > availableWidth {
|
||||||
contentPreview = contentPreview[:availableWidth-3] + "..."
|
contentPreview = contentPreview[:availableWidth-3] + "..."
|
||||||
|
@ -122,4 +122,4 @@ func listEntries(chat *chatpb.Chat) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("-------------------------------------------------")
|
fmt.Println("-------------------------------------------------")
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,4 +13,4 @@ func getTerminalWidth() int {
|
||||||
return 80
|
return 80
|
||||||
}
|
}
|
||||||
return width
|
return width
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue