Skip to content

Commit

Permalink
to version 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglei.w committed Mar 31, 2023
1 parent d3e2ecd commit c00ba4d
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
17 changes: 12 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
var (
pagePath = "wiki_pages"
wikiGit = "git@github.com:u2takey/gptwiki-pages.git"
Version = "0.1.0"
)

func main() {
Expand Down Expand Up @@ -102,7 +103,7 @@ func main() {
}
return nil
},
Version: "0.1",
Version: Version,
}

_ = app.Run(os.Args)
Expand Down Expand Up @@ -138,7 +139,7 @@ func SavePage(source, pages, folder, command, wiki, branch string) error {
//}
commandPath := GetWikiPathForCommand(pages, folder, command)
if err := ioutil.WriteFile(commandPath,
[]byte(fmt.Sprintf("#%s \n## chatgpt \n%s", command, wiki)), 0o666); err != nil {
[]byte(fmt.Sprintf("# %s \n## chatgpt \n%s", command, wiki)), 0o666); err != nil {
return err
}
//err = w.AddGlob("*")
Expand Down Expand Up @@ -225,15 +226,21 @@ func Init() *cli.Command {
&cli.StringFlag{Name: "chatgpt-key"},
&cli.StringFlag{Name: "folder", Value: "common"},
&cli.StringFlag{Name: "lang", Value: "zh"},
&cli.StringFlag{Name: "prompt", Value: "请详细解释命令:%s"},
&cli.StringFlag{Name: "prompt", Value: ""},
},
Action: func(c *cli.Context) error {
key := c.String("chatgpt-key")
folder := c.String("folder")
lang := c.String("lang")
prompt := c.String("prompt")
if len(lang) == 0 {
prompt = "Please explain the command in detail: %s"
if len(lang) > 0 {
if lang == "zh" && prompt == "" {
prompt = "请详细解释命令:%s"
}
} else {
if prompt == "" {
prompt = "Please explain the command in detail: %s"
}
}
config := Config{
GptKey: key,
Expand Down
53 changes: 53 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# All targets.
.PHONY: lint test build publish clean help

# Current version of the project.
VersionMain ?= 0.1.1


# Target binaries. You can build multiple binaries for a single project.
TARGETS := wiki
PLAT_FROM := linux darwin windows

# Project main package location (can be multiple ones).
CMD_DIR := .
# Project output directory.
OUTPUT_DIR := ./output
# Git commit sha.
COMMIT := $(shell git rev-parse --short HEAD)
# Build Date
BUILD_DATE=$(shelldate +%FT%T%z)
# Version File
VERSION_FILE=main

lint: ## use golint to do lint
golint ./...

test: ## test
go test -cover ./...

build: ## build local binary for targets on
@for target in $(TARGETS); do \
go build -o $(OUTPUT_DIR)/$${target} \
-ldflags "-s -w -X $(VERSION_FILE).Version=$(VersionMain)-$(COMMIT)" \
$(CMD_DIR)/.; \
done


build-all: # build cross for targets
@for plat in $(PLAT_FROM); do \
for target in $(TARGETS); do \
CGO_ENABLED=0 GOOS=$${plat} GOARCH=amd64 go build -o $(OUTPUT_DIR)/$${target}_$${plat}_amd64 \
-ldflags "-s -w -X $(VERSION_FILE).Version=$(VersionMain)-$(COMMIT)" \
$(CMD_DIR)/.; \
done \
done


.PHONY: clean
clean: # clean bin files
-rm -vrf ${OUTPUT_DIR}

.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
9 changes: 7 additions & 2 deletions scripts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Init() *cli.Command {
&cli.StringFlag{Name: "chatgpt-key"},
&cli.StringFlag{Name: "folder", Value: "common"},
&cli.StringFlag{Name: "lang", Value: "zh"},
&cli.StringFlag{Name: "prompt", Value: "请详细解释命令:%s"},
&cli.StringFlag{Name: "prompt", Value: ""},
&cli.BoolFlag{Name: "override", Value: false},
&cli.IntFlag{Name: "worker", Value: 10},
},
Expand All @@ -67,8 +67,13 @@ func Init() *cli.Command {
prompt := c.String("prompt")
if len(lang) > 0 {
pages += "." + lang
if lang == "zh" && prompt == "" {
prompt = "请详细解释命令:%s"
}
} else {
prompt = "Please explain the command in detail: %s"
if prompt == "" {
prompt = "Please explain the command in detail: %s"
}
}

fmt.Println("start", pages, folder)
Expand Down

0 comments on commit c00ba4d

Please sign in to comment.