diff mbox series

ip: Add examples to usage help

Message ID 20240211175704.5963-1-yedaya.ka@gmail.com (mailing list archive)
State Rejected
Delegated to: Stephen Hemminger
Headers show
Series ip: Add examples to usage help | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Yedaya Katsman Feb. 11, 2024, 5:57 p.m. UTC
Currently the usage only shows the syntax with all possible options,
which makes writing the most frequently used commands cumbersome, since it
requires parsing the syntax in your head. This praticularly affects
users new to the command, that resort to reading man pages or search
engines in order to find the correct invocations.

Copy over the examples from the man page, with the same indentation
for the command exaplanations that exist there. I removed the second
link example to save space.

The whole section is indented the same way the other sections in the usage
are, to keep the uniformity.

Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
---
 ip/ip.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Stephen Hemminger Feb. 11, 2024, 9 p.m. UTC | #1
On Sun, 11 Feb 2024 19:57:04 +0200
Yedaya Katsman <yedaya.ka@gmail.com> wrote:

> Currently the usage only shows the syntax with all possible options,
> which makes writing the most frequently used commands cumbersome, since it
> requires parsing the syntax in your head. This praticularly affects
> users new to the command, that resort to reading man pages or search
> engines in order to find the correct invocations.
> 
> Copy over the examples from the man page, with the same indentation
> for the command exaplanations that exist there. I removed the second
> link example to save space.
> 
> The whole section is indented the same way the other sections in the usage
> are, to keep the uniformity.
> 
> Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>

No.
Examples belong on man page, not the help message.
Help should be short and concise.
diff mbox series

Patch

diff --git a/ip/ip.c b/ip/ip.c
index e51fa206d282..78c3f130c593 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -73,7 +73,16 @@  static void usage(void)
 		"                    -l[oops] { maximum-addr-flush-attempts } | -echo | -br[ief] |\n"
 		"                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |\n"
 		"                    -rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] |\n"
-		"                    -c[olor]}\n");
+		"                    -c[olor]}\n"
+		"Examples: ip addr\n"
+		"              Shows addresses assigned to all network interfaces.\n"
+		"          ip neigh\n"
+		"              Shows the current neighbour table in kernel.\n"
+		"          ip link set x up\n"
+		"              Bring up interface x.\n"
+		"          ip route\n"
+		"              Show table routes.\n"
+		);
 	exit(-1);
 }