Show help when no arguments

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2018-05-10 13:48:20 +00:00
parent 357d5a0859
commit 873efb4f82
2 changed files with 24 additions and 7 deletions

View File

@@ -22,6 +22,24 @@ To build and install the latest version with [meson](http://mesonbuild.com):
The more classical autotools suite is also available but not recommended.
### Usage
Just run `glorytun` with no arguments to view the list of available commands:
```
$ glorytun
available commands:
show show all running tunnels
bench start a crypto bench
bind start a new tunnel
set change tunnel properties
keygen generate a new secret key
path manage paths
version show version
```
### Mini HowTo
Glorytun does not touch network configuration of its interface,

View File

@@ -69,15 +69,14 @@ main(int argc, char **argv)
{"version", "show version", gt_version},
{NULL}};
if (argc < 2)
return gt_show(argc, argv);
for (int k = 0; cmd[k].name; k++) {
if (!str_cmp(cmd[k].name, argv[1]))
return cmd[k].call(argc - 1, argv + 1);
if (argv[1]) {
for (int k = 0; cmd[k].name; k++) {
if (!str_cmp(cmd[k].name, argv[1]))
return cmd[k].call(argc - 1, argv + 1);
}
}
printf("unknown command `%s', available commands:\n\n", argv[1]);
printf("available commands:\n\n");
int len = 0;