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