feat(chat): add --get-next-auto-topic flag
This commit is contained in:
parent
82eba977cd
commit
a9b7fca08d
12
argv.go
12
argv.go
|
@ -17,12 +17,12 @@ type args struct {
|
|||
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"`
|
||||
CountAuto bool `arg:"--count-auto" help:"count the number of auto chats"`
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type EmptyCmd struct {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func doGetNextAutoTopic() {
|
||||
if err := me.chats.ConfigLoad(); err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
max := 0
|
||||
for _, chat := range me.chats.GetChats() {
|
||||
if strings.HasPrefix(chat.GetChatName(), "Auto ") {
|
||||
numStr := strings.TrimPrefix(chat.GetChatName(), "Auto ")
|
||||
num, err := strconv.Atoi(numStr)
|
||||
if err == nil && num > max {
|
||||
max = num
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Printf("Auto %d", max+1)
|
||||
}
|
16
main.go
16
main.go
|
@ -46,17 +46,15 @@ func main() {
|
|||
}
|
||||
|
||||
me.chats = chatpb.NewChats()
|
||||
if !argv.CountAuto {
|
||||
if err := me.chats.ConfigLoad(); err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
if verifyUuids(me.chats) {
|
||||
me.chats.ConfigSave()
|
||||
}
|
||||
if err := me.chats.ConfigLoad(); err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
if verifyUuids(me.chats) {
|
||||
me.chats.ConfigSave()
|
||||
}
|
||||
|
||||
if argv.CountAuto {
|
||||
doCountAuto()
|
||||
if argv.GetNextAutoTopic {
|
||||
doGetNextAutoTopic()
|
||||
okExit("")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue