nvram: add usage() function
authorBangLang Huang <banglang.huang@foxmail.com>
Fri, 24 Feb 2017 02:45:16 +0000 (10:45 +0800)
committerAlexander Couzens <lynxis@fe80.eu>
Tue, 22 Aug 2017 12:31:32 +0000 (14:31 +0200)
Merge the help message into a single function,
so that we can use it somewhere else.

Signed-off-by: BangLang Huang <banglang.huang@foxmail.com>
package/utils/nvram/src/cli.c

index 4f9c77804d793df4839fdd650f37f09fe9ee21fa..149d3074747fef3a21b8ef78c60dd7dd35c22ed9 100644 (file)
@@ -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;
        }