Added version flag

master
Aaron Johnon 9 months ago
parent 510091bbfa
commit 2b00d96627

@ -8,14 +8,16 @@ import (
"net/url"
"os"
"path/filepath"
"strings"
"strconv"
"strings"
"time"
"github.com/spf13/pflag"
"gopkg.in/yaml.v2"
)
var Version = "development"
type Config struct {
ChatID string `yaml:"CHATID"`
Token string `yaml:"TOKEN"`
@ -28,6 +30,7 @@ var (
token string
timeout int
silent bool
versionFlag bool
)
func init() {
@ -36,10 +39,17 @@ func init() {
pflag.StringVarP(&token, "token", "k", "", "Bot token value")
pflag.IntVarP(&timeout, "timeout", "t", 10, "Timeout value (defaults to 10)")
pflag.BoolVarP(&silent, "silent", "s", false, "Disable notification")
pflag.BoolVarP(&versionFlag, "version", "v", false, "Print version information and exit")
}
func main() {
pflag.Parse()
if versionFlag {
fmt.Printf("tbotsend version %s\n", Version)
os.Exit(0)
}
args := pflag.Args()
message := strings.Join(args, " ")
@ -183,4 +193,3 @@ func printFailure(msg string) {
func printSuccess() {
fmt.Fprintf(os.Stdout, "\033[1mResult:\033[0m [\033[1;32mSUCCESS\033[0m]\n\n")
}

Loading…
Cancel
Save