Skip to content

Commit

Permalink
chore: update text prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Apr 17, 2023
1 parent 578f60c commit b063f1c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 23 additions & 3 deletions common/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,30 @@ import (
"log"
"os"
"path/filepath"
"strings"
)

var (
Port = flag.Int("port", 3000, "the listening port")
PrintVersion = flag.Bool("version", false, "print version and exit")
LogDir = flag.String("log-dir", "", "specify the log directory")
PrintVersion = flag.Bool("version", false, "Print the version of the program and exits.")
PrintHelp = flag.Bool("help", false, "Print the help message and exits.")
Port = flag.Int("port", 3000, "Specify the listening port. Default is 3000.")
LogDir = flag.String("log-dir", "", "Specify the directory for log files.")
)

func printHelp() {
fmt.Println(fmt.Sprintf("Message Pusher %s - Your all in one message push system.", Version))
fmt.Println("Copyright (C) 2023 JustSong. All rights reserved.")
fmt.Println("GitHub: https://github.com/songquanpeng/message-pusher")
fmt.Println("Usage: message-pusher [options]")
fmt.Println("Options:")
flag.CommandLine.VisitAll(func(f *flag.Flag) {
name := fmt.Sprintf("-%s", f.Name)
usage := strings.Replace(f.Usage, "\n", "\n ", -1)
fmt.Printf(" -%-14s%s\n", name, usage)
})
os.Exit(0)
}

func init() {
flag.Parse()

Expand All @@ -22,6 +38,10 @@ func init() {
os.Exit(0)
}

if *PrintHelp {
printHelp()
}

if os.Getenv("SESSION_SECRET") != "" {
SessionSecret = os.Getenv("SESSION_SECRET")
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var indexPage []byte

func main() {
common.SetupGinLog()
common.SysLog("system started")
common.SysLog("Message Pusher " + common.Version + " started")
if os.Getenv("GIN_MODE") != "debug" {
gin.SetMode(gin.ReleaseMode)
}
Expand Down

0 comments on commit b063f1c

Please sign in to comment.