MCPcopy
hub / github.com/EverythingSuckz/TG-FileStreamBot / loadConfigFromArgs

Method loadConfigFromArgs

config/config.go:99–165  ·  view source on GitHub ↗
(log *zap.Logger, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

97}
98
99func (c *config) loadConfigFromArgs(log *zap.Logger, cmd *cobra.Command) {
100 apiID, _ := cmd.Flags().GetInt32("api-id")
101 if apiID != 0 {
102 os.Setenv("API_ID", strconv.Itoa(int(apiID)))
103 }
104 apiHash, _ := cmd.Flags().GetString("api-hash")
105 if apiHash != "" {
106 os.Setenv("API_HASH", apiHash)
107 }
108 botToken, _ := cmd.Flags().GetString("bot-token")
109 if botToken != "" {
110 os.Setenv("BOT_TOKEN", botToken)
111 }
112 logChannelID, _ := cmd.Flags().GetString("log-channel")
113 if logChannelID != "" {
114 os.Setenv("LOG_CHANNEL", logChannelID)
115 }
116 dev, _ := cmd.Flags().GetBool("dev")
117 if dev {
118 os.Setenv("DEV", strconv.FormatBool(dev))
119 }
120 port, _ := cmd.Flags().GetInt("port")
121 if port != 0 {
122 os.Setenv("PORT", strconv.Itoa(port))
123 }
124 host, _ := cmd.Flags().GetString("host")
125 if host != "" {
126 os.Setenv("HOST", host)
127 }
128 hashLength, _ := cmd.Flags().GetInt("hash-length")
129 if hashLength != 0 {
130 os.Setenv("HASH_LENGTH", strconv.Itoa(hashLength))
131 }
132 useSessionFile, _ := cmd.Flags().GetBool("use-session-file")
133 if useSessionFile {
134 os.Setenv("USE_SESSION_FILE", strconv.FormatBool(useSessionFile))
135 }
136 userSession, _ := cmd.Flags().GetString("user-session")
137 if userSession != "" {
138 os.Setenv("USER_SESSION", userSession)
139 }
140 usePublicIP, _ := cmd.Flags().GetBool("use-public-ip")
141 if usePublicIP {
142 os.Setenv("USE_PUBLIC_IP", strconv.FormatBool(usePublicIP))
143 }
144 multiTokens, _ := cmd.Flags().GetString("multi-token-txt-file")
145 if multiTokens != "" {
146 os.Setenv("MULTI_TOKEN_TXT_FILE", multiTokens)
147 // TODO: Add support for importing tokens from a separate file
148 }
149 streamConcurrency, _ := cmd.Flags().GetInt("stream-concurrency")
150 if streamConcurrency != 0 {
151 os.Setenv("STREAM_CONCURRENCY", strconv.Itoa(streamConcurrency))
152 }
153 streamBufferCount, _ := cmd.Flags().GetInt("stream-buffer-count")
154 if streamBufferCount != 0 {
155 os.Setenv("STREAM_BUFFER_COUNT", strconv.Itoa(streamBufferCount))
156 }

Callers 1

setupEnvVarsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected