Skip to content

[Bug] --config doesn't actually do anything #249

@TDodgeCo

Description

@TDodgeCo

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 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

  1. Add print statements on lines 48 and 52 of cmd/root.go, and line 18 of internal/util/path.go to monitor control flow.
  2. 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.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions