diff mbox series

[i2c-tools,1/3] i2ctransfer: sort command line options and add to help text

Message ID 20240807112159.14220-2-wsa+renesas@sang-engineering.com (mailing list archive)
State Handled Elsewhere
Delegated to: Geert Uytterhoeven
Headers show
Series i2ctransfer: cleanups & add binary data option | expand

Commit Message

Wolfram Sang Aug. 7, 2024, 11:21 a.m. UTC
Sort the options in docs and code. Describe them in the help text.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 tools/i2ctransfer.8 | 32 ++++++++++++++++----------------
 tools/i2ctransfer.c | 18 ++++++++++++------
 2 files changed, 28 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/tools/i2ctransfer.8 b/tools/i2ctransfer.8
index c88ef64..88d5eb3 100644
--- a/tools/i2ctransfer.8
+++ b/tools/i2ctransfer.8
@@ -4,10 +4,10 @@  i2ctransfer \- send user-defined I2C messages in one transfer
 
 .SH SYNOPSIS
 .B i2ctransfer
+.RB [ -a ]
 .RB [ -f ]
-.RB [ -y ]
 .RB [ -v ]
-.RB [ -a ]
+.RB [ -y ]
 .I i2cbus desc
 .RI [ data ]
 .RI [ desc
@@ -15,10 +15,10 @@  i2ctransfer \- send user-defined I2C messages in one transfer
 .RI ...
 .br
 .B i2ctransfer
-.B -V
+.B -h
 .br
 .B i2ctransfer
-.B -h
+.B -V
 
 .SH DESCRIPTION
 .B i2ctransfer
@@ -40,6 +40,9 @@  This program helps you to create proper transfers for your needs.
 
 .SH OPTIONS
 .TP
+.B -a
+Allow using addresses between 0x00 - 0x07 and 0x78 - 0x7f. Not recommended.
+.TP
 .B -f
 Force access to the device even if it is already busy.
 By default,
@@ -51,13 +54,8 @@  It can also cause
 to silently write to the wrong register.
 So use at your own risk and only if you know what you're doing.
 .TP
-.B -y
-Disable interactive mode.
-By default,
-.B i2ctransfer
-will wait for a confirmation from the user before messing with the I2C bus.
-When this flag is used, it will perform the operation directly.
-This is mainly meant to be used in scripts.
+.B -h
+Display the help and exit.
 .TP
 .B -v
 Enable verbose output.
@@ -66,11 +64,13 @@  It will print infos about all messages sent, i.e. not only for read messages but
 .B -V
 Display the version and exit.
 .TP
-.B -h
-Display the help and exit.
-.TP
-.B -a
-Allow using addresses between 0x00 - 0x07 and 0x78 - 0x7f. Not recommended.
+.B -y
+Disable interactive mode.
+By default,
+.B i2ctransfer
+will wait for a confirmation from the user before messing with the I2C bus.
+When this flag is used, it will perform the operation directly.
+This is mainly meant to be used in scripts.
 
 .SH ARGUMENTS
 .PP
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 85b70c3..15e774b 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -42,7 +42,13 @@  enum parse_state {
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2ctransfer [-f] [-y] [-v] [-V] [-a] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
+		"Usage: i2ctransfer [OPTIONS] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
+		"  OPTIONS: -a allow even reserved addresses\n"
+		"           -f force access even if address is marked used\n"
+		"           -h this help text\n"
+		"           -v verbose mode\n"
+		"           -V version info\n"
+		"           -y yes to all confirmations\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  DESC describes the transfer in the form: {r|w}LENGTH[@address]\n"
 		"    1) read/write-flag 2) LENGTH (range 0-65535, or '?')\n"
@@ -141,15 +147,15 @@  int main(int argc, char *argv[])
 		msgs[i].buf = NULL;
 
 	/* handle (optional) flags first */
-	while ((opt = getopt(argc, argv, "Vafhvy")) != -1) {
+	while ((opt = getopt(argc, argv, "afhvVy")) != -1) {
 		switch (opt) {
-		case 'V': version = 1; break;
-		case 'v': verbose = 1; break;
+		case 'a': all_addrs = 1; break;
 		case 'f': force = 1; break;
+		case 'v': verbose = 1; break;
+		case 'V': version = 1; break;
 		case 'y': yes = 1; break;
-		case 'a': all_addrs = 1; break;
-		case 'h':
 		case '?':
+		case 'h':
 			help();
 			exit(opt == '?');
 		}