fix: ignored TWT_TOKEN env variable
Hi !
Discovered this tool yesterday. I wondered why I can't pass TWT_TOKEN env variable to the CLI. It seems the variable is ignored.
I made this fix. It should deserve a test, but I don't know Rust so much.
Codecov Report
Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.
Project coverage is 19.26%. Comparing base (
882e816) to head (d368c95). Report is 1 commits behind head on main.
| Files | Patch % | Lines |
|---|---|---|
| src/handlers/config.rs | 0.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #592 +/- ##
=======================================
Coverage 19.26% 19.26%
=======================================
Files 41 41
Lines 5086 5086
=======================================
Hits 980 980
Misses 4106 4106
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hi! Thanks for the PR. Don't worry about the failing CI on formatting, I'll be testing this just on functionality.
Hi, If I tried to pass the variable as environment variable, I get this error. So I looked into the checking part.
Twitch config section is missing one or more of the following: username, channel, token.
I don't think the error is relative to a shell, as I got the same result from bash or zsh on Arch.
Here is the part of my script I am trying to run. The $ACCESSTOKEN is valid, tested directly in the twt config file.
streamlink -Q "--twitch-api-header=Authorization=Bearer $ACCESSTOKEN" https://www.twitch.tv/$selected_channel &
TWT_TOKEN="oauth:$ACCESSTOKEN" twt -c $selected_channel
Let me do some recheck. It's weird.
I also tried export TWT_TOKEN=*****. It doesn't change anything.
What version of twitch-tui are you on? I tried the same command as yours with my token, seemed to work fine.
I'm using twitch-tui 2.6.7 and rust 1.78.0. I did a fresh install on a different machine (Macbook) and I've got the same issue.
Fun story, and that's why I thought my PR fix the issue, when I run from the source, it works totally fine
TWT_TOKEN=*** cargo run
but if I run it with the binary, the environment variable is ignored. :mindblowing:
TWT_TOKEN=*** ./target/debug/twt
Do the changes in this PR fix the issue you're experiencing?
I updated the PR and changed the way the code get the variable, and everything seems fine now. Maybe an issue with the option_env macro.
Ah, yeah that might just fix it. I'll test it very soon. I have a feeling it's to do with option_env's way of checking for the variable:
Optionally inspects an environment variable at compile time.
Available in https://github.com/Xithrius/twitch-tui/releases/tag/v2.6.8