Gitea CLI doesn't fail if the command is invalid #9516

Open
opened 2025-11-02 08:41:26 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @dotdiego on GitHub (Sep 5, 2022).

Feature Description

I stumbled upon an issue/feature that could be nice for the cli.

I was trying to do this command
gitea user create --username test --password mysuperpassword --email test@test.com --admin

It was trying to create another server and i didn't understood why.
Then thanks to an great guy on Discord pointing that i misread the docs.
The correct base command was gitea admin user ...

But I think that the cli should have thrown an error because the command I sent was invalid.

I don't know if it's related to an issue or a feature improvement.

Screenshots

No response

Originally created by @dotdiego on GitHub (Sep 5, 2022). ### Feature Description I stumbled upon an issue/feature that could be nice for the cli. I was trying to do this command ` gitea user create --username test --password mysuperpassword --email test@test.com --admin` It was trying to create another server and i didn't understood why. Then thanks to an great guy on Discord pointing that i misread the docs. The correct base command was `gitea admin user ...` But I think that the cli should have thrown an error because the command I sent was invalid. I don't know if it's related to an issue or a feature improvement. ### Screenshots _No response_
GiteaMirror added the type/enhancementtype/proposal labels 2025-11-02 08:41:26 -06:00
Author
Owner

@jolheiser commented on GitHub (Sep 10, 2022):

Currently the base command gitea acts as an alias to gitea web

754861a020/main.go (L108)

This has been the case for as long as I can remember, and it's something I've thought about whether to change a few times.

It would be a breaking change to alter this behavior, but I think it may save some headaches like this one.


To do so, I think we would need to

  1. Make sure our docs appropriately use gitea web as necessary (which I think they mostly do already)
  2. Think about a grace release where a warning appears prior to breaking
  3. Discuss what the base command should do, if anything. imo it would be nice to show hypothetical information/stats without actually needing them; that is, things like data path, log path, etc. without actually attempting mkdirall
  4. Perhaps at least check for superfluous arguments and give a warning. For example,
    gitea user create --username test --password mysuperpassword --email test@test.com --admin
    is the "same" as
    gitea web user create --username test --password mysuperpassword --email test@test.com --admin
    Where the CLI could potentially detect "I was passed a bunch of flags and args that have nothing to do with this command, maybe the user did something unexpected?"
@jolheiser commented on GitHub (Sep 10, 2022): Currently the base command `gitea` acts as an alias to `gitea web` https://github.com/go-gitea/gitea/blob/754861a020b4160140d6fb1e4351018fb9ae9374/main.go#L108 This has been the case for as long as I can remember, and it's something I've thought about whether to change a few times. It would be a breaking change to alter this behavior, but I think it may save some headaches like this one. ----- To do so, I think we would need to 1. Make sure our docs appropriately use `gitea web` as necessary (which I think they mostly do already) 2. Think about a grace release where a warning appears prior to breaking 3. Discuss what the base command _should_ do, if anything. imo it would be nice to show hypothetical information/stats without actually needing them; that is, things like data path, log path, etc. without actually attempting mkdirall 4. Perhaps at least check for superfluous arguments and give a warning. For example, `gitea user create --username test --password mysuperpassword --email test@test.com --admin` is the "same" as `gitea web user create --username test --password mysuperpassword --email test@test.com --admin` Where the CLI could potentially detect "I was passed a bunch of flags and args that have nothing to do with this command, maybe the user did something unexpected?"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9516