Fix JIRA_DEBUG env var being ignored by most commands - #24
Merged
Conversation
Every subcommand except `jira init` read the --debug flag directly
off the pflag object (cmd.Flags().GetBool("debug") /
flags.GetBool("debug")), which only picks up the command-line flag
and never consults viper's env var binding. `jira init` already read
debug via viper.GetBool("debug"), so JIRA_DEBUG worked there but
nowhere else.
Switch all remaining call sites to viper.GetBool("debug"), matching
the pattern in internal/config/generator.go. viper.AutomaticEnv() +
SetEnvPrefix("jira") in root.go makes JIRA_DEBUG resolve correctly,
and the --debug flag continues to take precedence since it's already
bound via viper.BindPFlag("debug", ...) in root.go, so existing
--debug behavior is unchanged.
…iption Two call sites still read debug off the pflag object, so JIRA_DEBUG was ignored there. internal/query/issue.go gates the JQL debug print, which left 'jira issue list' half-debugging: the API client honored the env var but the JQL line never printed.
rethab
added a commit
that referenced
this pull request
Aug 5, 2026
Addresses ankitpokhrel#930. `jira init` reads the debug setting via `viper.GetBool("debug")`, so `JIRA_DEBUG` works there. Every other subcommand instead reads debug directly off the pflag object with `cmd.Flags().GetBool("debug")` or `flags.GetBool("debug")`, which never consults viper or the env var, only the `--debug` flag on the command line. As a result `JIRA_DEBUG=true jira issue view ...` (and the equivalent for every other subcommand) silently did nothing. This switches all remaining call sites (issue, epic, sprint, board, project, release and serverinfo commands, plus the sprint query params) to `viper.GetBool("debug")`, mirroring the pattern already used in `internal/config/generator.go`. Since `--debug` is already bound via `viper.BindPFlag("debug", ...)` in `internal/cmd/root/root.go`, and `viper.AutomaticEnv()` + `SetEnvPrefix("jira")` are configured there too, this makes `JIRA_DEBUG` resolve consistently everywhere while leaving existing `--debug` flag behavior unchanged. Also added a test in `internal/query/sprint_test.go` covering that `JIRA_DEBUG` is picked up when constructing sprint query params.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses ankitpokhrel#930.
jira initreads the debug setting viaviper.GetBool("debug"), soJIRA_DEBUGworks there. Every other subcommand instead reads debug directly off the pflag object withcmd.Flags().GetBool("debug")orflags.GetBool("debug"), which never consults viper or the env var, only the--debugflag on the command line. As a resultJIRA_DEBUG=true jira issue view ...(and the equivalent for every other subcommand) silently did nothing.This switches all remaining call sites (issue, epic, sprint, board, project, release and serverinfo commands, plus the sprint query params) to
viper.GetBool("debug"), mirroring the pattern already used ininternal/config/generator.go. Since--debugis already bound viaviper.BindPFlag("debug", ...)ininternal/cmd/root/root.go, andviper.AutomaticEnv()+SetEnvPrefix("jira")are configured there too, this makesJIRA_DEBUGresolve consistently everywhere while leaving existing--debugflag behavior unchanged.Also added a test in
internal/query/sprint_test.gocovering thatJIRA_DEBUGis picked up when constructing sprint query params.