Better help message printing for command line tool
authorClifford Wolf <clifford@clifford.at>
Sat, 27 Dec 2014 10:01:59 +0000 (11:01 +0100)
committerClifford Wolf <clifford@clifford.at>
Sat, 27 Dec 2014 10:01:59 +0000 (11:01 +0100)
kernel/driver.cc

index 6ba0c1134ba2a50d6b5b5c9eeda367af22e1c6e6..90f4793079f548ed3973b39e97b6a98bb053531f 100644 (file)
@@ -92,6 +92,82 @@ int main(int argc, char **argv)
        }
 #endif
 
+       if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "-help") || !strcmp(argv[1], "--help")))
+       {
+               printf("\n");
+               printf("Usage: %s [options] [<infile> [..]]\n", argv[0]);
+               printf("\n");
+               printf("    -Q\n");
+               printf("        suppress printing of banner (copyright, disclaimer, version)\n");
+               printf("\n");
+               printf("    -T\n");
+               printf("        suppress printing of footer (log hash, version, timing statistics)\n");
+               printf("\n");
+               printf("    -q\n");
+               printf("        quiet operation. only write warnings and error messages to console\n");
+               printf("        use this option twice to also quiet warning messages\n");
+               printf("\n");
+               printf("    -v <level>\n");
+               printf("        print log headers up to level <level> to the console. (implies -q)\n");
+               printf("\n");
+               printf("    -t\n");
+               printf("        annotate all log messages with a time stamp\n");
+               printf("\n");
+               printf("    -d\n");
+               printf("        print more detailed timing stats at exit\n");
+               printf("\n");
+               printf("    -l logfile\n");
+               printf("        write log messages to the specified file\n");
+               printf("\n");
+               printf("    -o outfile\n");
+               printf("        write the design to the specified file on exit\n");
+               printf("\n");
+               printf("    -b backend\n");
+               printf("        use this backend for the output file specified on the command line\n");
+               printf("\n");
+               printf("    -f backend\n");
+               printf("        use the specified front for the input files on the command line\n");
+               printf("\n");
+               printf("    -H\n");
+               printf("        print the command list\n");
+               printf("\n");
+               printf("    -h command\n");
+               printf("        print the help message for the specified command\n");
+               printf("\n");
+               printf("    -s scriptfile\n");
+               printf("        execute the commands in the script file\n");
+               printf("\n");
+               printf("    -c tcl_scriptfile\n");
+               printf("        execute the commands in the tcl script file (see 'help tcl' for details)\n");
+               printf("\n");
+               printf("    -p command\n");
+               printf("        execute the commands\n");
+               printf("\n");
+               printf("    -m module_file\n");
+               printf("        load the specified module (aka plugin)\n");
+               printf("\n");
+               printf("    -A\n");
+               printf("        will call abort() at the end of the script. useful for debugging\n");
+               printf("\n");
+               printf("    -V\n");
+               printf("        print version information and exit\n");
+               printf("\n");
+               printf("The option -S is an shortcut for calling the \"synth\" command, a default\n");
+               printf("script for transforming the verilog input to a gate-level netlist. For example:\n");
+               printf("\n");
+               printf("    yosys -o output.blif -S input.v\n");
+               printf("\n");
+               printf("For more complex synthesis jobs it is recommended to use the read_* and write_*\n");
+               printf("commands in a script file instead of specifying input and output files on the\n");
+               printf("command line.\n");
+               printf("\n");
+               printf("When no commands, script files or input files are specified on the command\n");
+               printf("line, yosys automatically enters the interactive command mode. Use the 'help'\n");
+               printf("command to get information on the individual commands.\n");
+               printf("\n");
+               exit(0);
+       }
+
        int opt;
        while ((opt = getopt(argc, argv, "AQTVSm:f:Hh:b:o:p:l:qv:tds:c:")) != -1)
        {
@@ -165,78 +241,7 @@ int main(int argc, char **argv)
                        scriptfile_tcl = true;
                        break;
                default:
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "Usage: %s [-V -S -Q -T -q] [-v <level>[-t] [-l <logfile>] [-o <outfile>] [-f <frontend>] [-h cmd] \\\n", argv[0]);
-                       fprintf(stderr, "       %*s[{-s|-c} <scriptfile>] [-p <pass> [-p ..]] [-b <backend>] [-m <module_file>] [<infile> [..]]\n", int(strlen(argv[0])+1), "");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -Q\n");
-                       fprintf(stderr, "        suppress printing of banner (copyright, disclaimer, version)\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -T\n");
-                       fprintf(stderr, "        suppress printing of footer (log hash, version, timing statistics)\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -q\n");
-                       fprintf(stderr, "        quiet operation. only write warnings and error messages to console\n");
-                       fprintf(stderr, "        use this option twice to also quiet warning messages\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -v <level>\n");
-                       fprintf(stderr, "        print log headers up to level <level> to the console. (implies -q)\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -t\n");
-                       fprintf(stderr, "        annotate all log messages with a time stamp\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -d\n");
-                       fprintf(stderr, "        print more detailed timing stats at exit\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -l logfile\n");
-                       fprintf(stderr, "        write log messages to the specified file\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -o outfile\n");
-                       fprintf(stderr, "        write the design to the specified file on exit\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -b backend\n");
-                       fprintf(stderr, "        use this backend for the output file specified on the command line\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -f backend\n");
-                       fprintf(stderr, "        use the specified front for the input files on the command line\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -H\n");
-                       fprintf(stderr, "        print the command list\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -h command\n");
-                       fprintf(stderr, "        print the help message for the specified command\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -s scriptfile\n");
-                       fprintf(stderr, "        execute the commands in the script file\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -c tcl_scriptfile\n");
-                       fprintf(stderr, "        execute the commands in the tcl script file (see 'help tcl' for details)\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -p command\n");
-                       fprintf(stderr, "        execute the commands\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -m module_file\n");
-                       fprintf(stderr, "        load the specified module (aka plugin)\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -A\n");
-                       fprintf(stderr, "        will call abort() at the end of the script. useful for debugging\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    -V\n");
-                       fprintf(stderr, "        print version information and exit\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "The option -S is an shortcut for calling the \"synth\" command, a default\n");
-                       fprintf(stderr, "script for transforming the verilog input to a gate-level netlist. For example:\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "    yosys -o output.blif -S input.v\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "For more complex synthesis jobs it is recommended to use the read_* and write_*\n");
-                       fprintf(stderr, "commands in a script file instead of specifying input and output files on the\n");
-                       fprintf(stderr, "command line.\n");
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "When no commands, script files or input files are specified on the command\n");
-                       fprintf(stderr, "line, yosys automatically enters the interactive command mode. Use the 'help'\n");
-                       fprintf(stderr, "command to get information on the individual commands.\n");
-                       fprintf(stderr, "\n");
+                       fprintf(stderr, "Run '%s -h' for help.\n", argv[0]);
                        exit(1);
                }
        }