]> granicus.if.org Git - llvm/commitdiff
[llvm-ar] Parse 'h' and '-h': display help and exit
authorFangrui Song <maskray@google.com>
Tue, 17 Sep 2019 09:25:52 +0000 (09:25 +0000)
committerFangrui Song <maskray@google.com>
Tue, 17 Sep 2019 09:25:52 +0000 (09:25 +0000)
Support `llvm-ar h` and `llvm-ar -h` because they may be what users try
at first. Note, operation 'h' is undocumented in GNU ar.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D67560

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372088 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-ar/help-message.test [new file with mode: 0644]
tools/llvm-ar/llvm-ar.cpp

diff --git a/test/tools/llvm-ar/help-message.test b/test/tools/llvm-ar/help-message.test
new file mode 100644 (file)
index 0000000..ed17667
--- /dev/null
@@ -0,0 +1,6 @@
+# RUN: llvm-ar h | FileCheck %s
+# RUN: llvm-ar -h | FileCheck %s
+# RUN: llvm-ar -help | FileCheck %s
+# RUN: llvm-ar --help | FileCheck %s
+
+# CHECK: USAGE: llvm-ar
index 9447298421b7dba3e70e688693728898c5ff0772..006d8ed74cf29575c5d3c224338ca3976f98e98d 100644 (file)
@@ -70,14 +70,14 @@ USAGE: llvm-ar [options] [-]<operation>[modifiers] [relpos] [count] <archive> [f
        llvm-ar -M [<mri-script]
 
 OPTIONS:
-  --format              - Archive format to create
+  --format              - archive format to create
     =default            -   default
     =gnu                -   gnu
     =darwin             -   darwin
     =bsd                -   bsd
-  --plugin=<string>     - Ignored for compatibility
-  --help                - Display available options
-  --version             - Display the version of this program
+  --plugin=<string>     - ignored for compatibility
+  -h --help             - display this help and exit
+  --version             - print the version and exit
   @<file>               - read options from <file>
 
 OPERATIONS:
@@ -1030,7 +1030,7 @@ static void runMRIScript() {
 }
 
 static bool handleGenericOption(StringRef arg) {
-  if (arg == "-help" || arg == "--help") {
+  if (arg == "h" || arg.startswith("-h") || arg == "--help") {
     printHelpMessage();
     return true;
   }