[source] nvram: add usage() function

LEDE Commits lede-commits at lists.infradead.org
Tue Aug 22 05:32:31 PDT 2017


lynxis pushed a commit to source.git, branch master:
https://git.lede-project.org/2a253e7cdbacd1bd19da80ea6f35a93b42655c3b

commit 2a253e7cdbacd1bd19da80ea6f35a93b42655c3b
Author: BangLang Huang <banglang.huang at foxmail.com>
AuthorDate: Fri Feb 24 10:45:16 2017 +0800

    nvram: add usage() function
    
    Merge the help message into a single function,
    so that we can use it somewhere else.
    
    Signed-off-by: BangLang Huang <banglang.huang at foxmail.com>
---
 package/utils/nvram/src/cli.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/package/utils/nvram/src/cli.c b/package/utils/nvram/src/cli.c
index 4f9c778..149d307 100644
--- a/package/utils/nvram/src/cli.c
+++ b/package/utils/nvram/src/cli.c
@@ -133,6 +133,18 @@ static int do_info(nvram_handle_t *nvram)
 	return 0;
 }
 
+static void usage(void)
+{
+	fprintf(stderr,
+		"Usage:\n"
+		"	nvram show\n"
+		"	nvram info\n"
+		"	nvram get variable\n"
+		"	nvram set variable=value [set ...]\n"
+		"	nvram unset variable [unset ...]\n"
+		"	nvram commit\n"
+	);
+}
 
 int main( int argc, const char *argv[] )
 {
@@ -233,16 +245,7 @@ int main( int argc, const char *argv[] )
 	}
 	else if( !done )
 	{
-		fprintf(stderr,
-			"Usage:\n"
-			"	nvram show\n"
-			"	nvram info\n"
-			"	nvram get variable\n"
-			"	nvram set variable=value [set ...]\n"
-			"	nvram unset variable [unset ...]\n"
-			"	nvram commit\n"
-		);
-
+		usage();
 		stat = 1;
 	}
 



More information about the lede-commits mailing list