Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--quiet is not usable as a global option with gitea web #22361

Closed
mqudsi opened this issue Jan 7, 2023 · 0 comments · Fixed by #25537
Closed

--quiet is not usable as a global option with gitea web #22361

mqudsi opened this issue Jan 7, 2023 · 0 comments · Fixed by #25537
Labels

Comments

@mqudsi
Copy link
Contributor

mqudsi commented Jan 7, 2023

Description

Per gitea --help, the correct order of arguments is as follows:

gitea [global options] command [command options] [arguments...]

and the global options list includes

GLOBAL OPTIONS:
   ...
   --quiet, -q                    Only display Fatal logging errors until logging is set-up
   --verbose                      Set initial logging to TRACE level until logging is properly set-up

However, executing gitea -q web does not work (the initial logger level is still Info rather than Fatal) while gitea web -q does work.

It seems quiet is actually defined as a subcommand-specific cli boolean flag in web.go for the web subcommand associated with the runWeb action:

gitea/cmd/web.go

Lines 51 to 53 in d42b52f

cli.BoolFlag{
Name: "quiet, q",
Usage: "Only display Fatal logging errors until logging is set-up",

I'd file a PR but I'm not clear on the intended behavior. It seems that the concept of global options might be altogether incorrect here since the switch is defined for a specific command and in runWeb the context associated with that particular command is queried for quiet, so it seems like you might prefer that the output/organization of gitea --help be patched rather than the actual querying behavior. I'm not sure if --quiet was previously a global option and now it's a command-specific one or if it's really only meant when running gitea -q rather than gitea -q web.

Gitea Version

1.19.0+dev-43-g57df0f116

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

N/A

Operating System

FreeBSD

How are you running Gitea?

Self-hosted, from the command-line.

Database

PostgreSQL

@mqudsi mqudsi added the type/bug label Jan 7, 2023
silverwind pushed a commit that referenced this issue Jun 28, 2023
More fix for #24981

* #24981


Close #22361

* #22361

There were many patches for Gitea's sub-commands to satisfy the facts:

* Some sub-commands shouldn't output any log, otherwise the git protocol
would be broken
* Sometimes the users want to see "verbose" or "quiet" outputs

That's a longstanding problem, and very fragile. This PR is only a quick
patch for the problem.

In the future, the sub-command system should be refactored to a clear
solution.

----

Other changes:

* Use `ReplaceAllWriters` to replace
`RemoveAllWriters().AddWriters(writer)`, then it's an atomic operation.
* Remove unnecessary `syncLevelInternal` calls, because
`AddWriters/addWritersInternal` already calls it.

Co-authored-by: Giteabot <teabot@gitea.io>
wxiaoguang added a commit to wxiaoguang/gitea that referenced this issue Jun 28, 2023
More fix for go-gitea#24981

* go-gitea#24981


Close go-gitea#22361

* go-gitea#22361

There were many patches for Gitea's sub-commands to satisfy the facts:

* Some sub-commands shouldn't output any log, otherwise the git protocol
would be broken
* Sometimes the users want to see "verbose" or "quiet" outputs

That's a longstanding problem, and very fragile. This PR is only a quick
patch for the problem.

In the future, the sub-command system should be refactored to a clear
solution.

----

Other changes:

* Use `ReplaceAllWriters` to replace
`RemoveAllWriters().AddWriters(writer)`, then it's an atomic operation.
* Remove unnecessary `syncLevelInternal` calls, because
`AddWriters/addWritersInternal` already calls it.

Co-authored-by: Giteabot <teabot@gitea.io>
lunny pushed a commit that referenced this issue Jun 28, 2023
Backport #25537

More fix for #24981

* #24981

Close #22361, #25552

* #22361
* #25552

There were many patches for Gitea's sub-commands to satisfy the facts:

* Some sub-commands shouldn't output any log, otherwise the git protocol
would be broken
* Sometimes the users want to see "verbose" or "quiet" outputs

That's a longstanding problem, and very fragile. This PR is only a quick
patch for the problem.

In the future, the sub-command system should be refactored to a clear
solution.

----

Other changes:

* Use `ReplaceAllWriters` to replace
`RemoveAllWriters().AddWriters(writer)`, then it's an atomic operation.
* Remove unnecessary `syncLevelInternal` calls, because
`AddWriters/addWritersInternal` already calls it.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant