<commit_before>package action

import (
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"github.com/spf13/viper"
	"github.com/BluePecker/JwtAuth/daemon"
	"os"
	"fmt"
)

type Storage struct {
	Driver string
	Opts   string
}

type TLS struct {
	Key  string
	Cert string
}

type Args struct {
	PidFile  string
	LogFile  string
	LogLevel string
	Version  bool
	SockFile string
	Port     int
	Host     string
	Conf     string
	Secret   string
	Daemon   bool

	TLS     TLS
	Storage Storage
}

type RootCommand struct {
	Args  Args
	Cmd   *cobra.Command
	Viper *viper.Viper
}

var RootCmd *RootCommand = &RootCommand{}

func UsageTemplate() string {
	return `Usage:{{if .Runnable}}{{if .HasAvailableFlags}}
  {{appendIfNotPresent .UseLine "[OPTIONS] COMMAND [arg...]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
  {{ .CommandPath}} [command]
  {{end}}{{if gt .Aliases 0}}
Aliases:{{.NameAndAliases}}
{{end}}{{if .HasExample}}
Examples:{{ .Example }}
{{end}}{{ if .HasAvailableLocalFlags}}
Options:
{{.LocalFlags.FlagUsages | trimRightSpace}}
{{end}}{{ if .HasAvailableSubCommands}}
Commands:{{range .Commands}}{{if .IsAvailableCommand}}
  {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
{{end}}{{ if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimRightSpace}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsHelpCommand}}
  {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableSubCommands }}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`
}

func init() {
	RootCmd.Viper = viper.GetViper()

	RootCmd.Cmd = &cobra.Command{
		SilenceErrors: true,
		Use:           "jwt",
		Short:         "Jwt auth server",
		Long:          "User login information verification service",
		RunE: func(cmd *cobra.Command, args []string) error {
			if _, err := os.Stat(RootCmd.Args.Conf); err == nil {
				RootCmd.Viper.SetConfigFile(RootCmd.Args.Conf)
				if err := RootCmd.Viper.ReadInConfig(); err != nil {
					return err
				}
			}

			fmt.Println(cmd, "------------", args)

			RootCmd.Args.Port = RootCmd.Viper.GetInt("port")<commit_msg>remove println<commit_after>package action

import (
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"github.com/spf13/viper"
	"github.com/BluePecker/JwtAuth/daemon"
	"os"
	"fmt"
)

type Storage struct {
	Driver string
	Opts   string
}

type TLS struct {
	Key  string
	Cert string
}

type Args struct {
	PidFile  string
	LogFile  string
	LogLevel string
	Version  bool
	SockFile string
	Port     int
	Host     string
	Conf     string
	Secret   string
	Daemon   bool

	TLS     TLS
	Storage Storage
}

type RootCommand struct {
	Args  Args
	Cmd   *cobra.Command
	Viper *viper.Viper
}

var RootCmd *RootCommand = &RootCommand{}

func UsageTemplate() string {
	return `Usage:{{if .Runnable}}{{if .HasAvailableFlags}}
  {{appendIfNotPresent .UseLine "[OPTIONS] COMMAND [arg...]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
  {{ .CommandPath}} [command]
  {{end}}{{if gt .Aliases 0}}
Aliases:{{.NameAndAliases}}
{{end}}{{if .HasExample}}
Examples:{{ .Example }}
{{end}}{{ if .HasAvailableLocalFlags}}
Options:
{{.LocalFlags.FlagUsages | trimRightSpace}}
{{end}}{{ if .HasAvailableSubCommands}}
Commands:{{range .Commands}}{{if .IsAvailableCommand}}
  {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
{{end}}{{ if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimRightSpace}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsHelpCommand}}
  {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableSubCommands }}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`
}

func init() {
	RootCmd.Viper = viper.GetViper()

	RootCmd.Cmd = &cobra.Command{
		SilenceErrors: true,
		Use:           "jwt",
		Short:         "Jwt auth server",
		Long:          "User login information verification service",
		RunE: func(cmd *cobra.Command, args []string) error {
			if _, err := os.Stat(RootCmd.Args.Conf); err == nil {
				RootCmd.Viper.SetConfigFile(RootCmd.Args.Conf)
				if err := RootCmd.Viper.ReadInConfig(); err != nil {
					return err
				}
			}

			RootCmd.Args.Port = RootCmd.Viper.GetInt("port")
{'fraction_non_alphanumeric': 0.16475183823529413, 'fraction_numerical': 0.003216911764705882, 'mean_word_length': 4.097189695550352, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '302102', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1525, 'n_words': 348}