Possibly related to #144. There was a change to root.go a few days before the responder commented, and I'm wondering if maybe they just hadn't updated yet.
--config just plain doesn't work. Doesn't do anything. At least in my environment. (Windows 10, cmder)
I think it's because there's no *Run definition on the &cobra.Command struct in root.go. But my familiarity with Go (and thusly cobra/viper) is shaky at best, and I could be totally wrong on that.
I don't think the value of the flag is ever actually being read, or if it is, it's not being provided to the initConfig() function that manages whether or not to use the provided config file or generate one
Operating System
Windows 10 - Using cmder as cmd
Architecture Version (x86, x64, arm, etc)
x86
Steps to reproduce
Add print statements on lines 48 and 52 of cmd/root.go, and line 18 of internal/util/path.go to monitor control flow.
Create a .twitch-cli.env file with CLIENTID and CLIENTSECRET variables populated with your app's values. Place this file at the root directory of twitch-cli package.
Run any twitch command with the --config ./.twitch-cli.env flag.
Relevant log output
**Verify that my .twitch-cli.env file exists**
C:\Users\ME\go\src\github.com\ME\twitch-cli (main -> origin)
λ [ -f "./.twitch-cli.env" ] && echo true || echo false
true
**Contents of .twitch-cli.env file**
CLIENTSECRET={MyClientSecret}
CLIENTID={MyClientId}
**Attempt twitch configure with --config**
C:\Users\ME\go\src\github.com\ME\twitch-cli (main -> origin)
λ twitch-cli configure --config ./.twitch-cli.env
path.go - Line 18. If this message is printed, it means path was generated instead of read through the persistent flag.
root.go - Line 52. If this message is printed, it means that cfgFile was empty.
path.go - Line 18. If this message is printed, it means path was generated instead of read through the persistent flag.
**Attempt twitch token with --config**
C:\Users\ME\go\src\github.com\ME\twitch-cli (main -> origin)
λ twitch-cli token --config ./.twitch-cli.env
path.go - Line 18. If this message is printed, it means path was generated instead of read through the persistent flag.
root.go - Line 52. If this message is printed, it means that cfgFile was empty.
path.go - Line 18. If this message is printed, it means path was generated instead of read through the persistent flag.
No Client ID or Secret found in configuration. Triggering configuration now.
NOTE: I tried enclosing the path string in quotes as well. Same result.
What is the problem?
Possibly related to #144. There was a change to
root.go
a few days before the responder commented, and I'm wondering if maybe they just hadn't updated yet.--config
just plain doesn't work. Doesn't do anything. At least in my environment. (Windows 10, cmder)I think it's because there's no
*Run
definition on the&cobra.Command
struct inroot.go
. But my familiarity with Go (and thusly cobra/viper) is shaky at best, and I could be totally wrong on that.I don't think the value of the flag is ever actually being read, or if it is, it's not being provided to the
initConfig()
function that manages whether or not to use the provided config file or generate oneOperating System
Windows 10 - Using cmder as cmd
Architecture Version (x86, x64, arm, etc)
x86
Steps to reproduce
cmd/root.go
, and line 18 ofinternal/util/path.go
to monitor control flow..twitch-cli.env
file withCLIENTID
andCLIENTSECRET
variables populated with your app's values. Place this file at the root directory oftwitch-cli
package.twitch
command with the--config ./.twitch-cli.env
flag.Relevant log output
NOTE: I tried enclosing the path string in quotes as well. Same result.