Skip to content

Conversation

@shwoop
Copy link
Contributor

@shwoop shwoop commented Aug 28, 2025

The commands are not discoverable:

/workspaces/gluetun al-help ?2 ❯ ./gluetun --help                                                                                                                                                                                            root@02133880e5ee
2025-08-28T13:31:26Z ERROR command is unknown: --help
2025-08-28T13:31:26Z INFO Shutdown successful
/workspaces/gluetun al-help ?2 ❯ ./gluetun help                                                                                                                                                                                              root@02133880e5ee
2025-08-28T13:31:30Z ERROR command is unknown: help
2025-08-28T13:31:30Z INFO Shutdown successful
/workspaces/gluetun al-help ?2 ❯ ./gluetun udpate                                                                                                                                                                                            root@02133880e5ee
2025-08-28T13:31:44Z ERROR command is unknown: udpate
2025-08-28T13:31:44Z INFO Shutdown successful

I was only aware of them because I happened to snoop around the codebase.

Ironically, as we use flags, some of the commands do have help text:

/workspaces/gluetun al-help ?2 ❯ ./gluetun update --help
Usage of update:
  -all
        Update servers for all VPN providers
  -dns string
        DNS resolver address to use (default "8.8.8.8")
  -enduser
        Write results to /gluetun/servers.json (for end users)
  -ip-token string
        IP data service token (e.g. ipinfo.io) to use
  -maintainer
        Write results to ./internal/storage/servers.json to modify the program (for maintainers)
  -minratio float
        Minimum ratio of servers to find for the update to succeed (default 0.8)
  -providers string
        CSV string of VPN providers to update server data for

This PR adds new help text when a use provides -help or --help, the help text is printed by default:

/workspaces/gluetun al-help ⇡1 !1 ❯ ./gluetun-help --help
Usage: gluetun [COMMAND [OPTIONS]]

Lightweight swiss-army-knife-like VPN client to multiple VPN service providers.

Commands:
  version               Print the version of gluetun
  update                Update the VPN providers and servers
  healthcheck           Check the health of the VPN connection
  openvpnconfig         Print the OpenVPN configuration (for debugging)
  format-servers        Format the servers into a format that can be used by OpenVPN
  genkey                Generate a new OpenVPN key
/workspaces/gluetun al-help ⇡1 !1 ❯ ./gluetun-help -help
Usage: gluetun [COMMAND [OPTIONS]]

Lightweight swiss-army-knife-like VPN client to multiple VPN service providers.

Commands:
  version               Print the version of gluetun
  update                Update the VPN providers and servers
  healthcheck           Check the health of the VPN connection
  openvpnconfig         Print the OpenVPN configuration (for debugging)
  format-servers        Format the servers into a format that can be used by OpenVPN
  genkey                Generate a new OpenVPN key
/workspaces/gluetun al-help ⇡1 !1 ❯ ./gluetun-help udpate
Usage: gluetun [COMMAND [OPTIONS]]

Lightweight swiss-army-knife-like VPN client to multiple VPN service providers.

Commands:
  version               Print the version of gluetun
  update                Update the VPN providers and servers
  healthcheck           Check the health of the VPN connection
  openvpnconfig         Print the OpenVPN configuration (for debugging)
  format-servers        Format the servers into a format that can be used by OpenVPN
  genkey                Generate a new OpenVPN key
2025-08-28T13:42:52Z ERROR command is unknown: udpate
2025-08-28T13:42:52Z INFO Shutdown successful

@shwoop shwoop marked this pull request as ready for review August 28, 2025 13:48
Copy link
Owner

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, a few adjustments to be made + eventual refactor of other code parts

"fmt"
)

func (c *CLI) Help() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in order to later not forget to add a help message... it would be cool if each command be a struct implementing the interface

type Command interface {
    Run() error
    Name() string // for example "help", "genkey"
    Description() string // for example "Update the VPN servers data for some or all providers"
}

And then the help command would take a slice of all commands to print the help message? That would require to refactor a bit existing commands, so it's fine if you want to skip this comment as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made an attempt at a refactor with 2af3d40, let me know what you think.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll review shortly, just rushing for a v3.41.0 release currently.

@shwoop shwoop requested a review from qdm12 September 12, 2025 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants