Skip to content

Commit fc2b4f3

Browse files
committed
[readtapi] Cleanup printing command line options (llvm#75106)
Also, add a version option. (cherry picked from commit 142e567)
1 parent cd21058 commit fc2b4f3

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

llvm/test/tools/llvm-readtapi/command-line.test

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
; RUN: not llvm-readtapi -merge -compare -compact %t/tmp.tbd %t/tmp2.tbd 2>&1 | FileCheck %s --check-prefix MULTI_ACTION
55
// Check unsupported file output format.
66
; RUN: not llvm-readtapi -merge -compact %t/tmp.tbd %t/tmp2.tbd --filetype=tbd-v2 2>&1 | FileCheck %s --check-prefix FILE_FORMAT
7+
// Check version printing.
8+
; RUN: llvm-readtapi -v 2>&1 | FileCheck %s --check-prefix VERSION
9+
; RUN: llvm-readtapi --version 2>&1 | FileCheck %s --check-prefix VERSION
710

8-
CHECK: OVERVIEW: LLVM TAPI file reader and manipulator
9-
CHECK: USAGE: llvm-readtapi [options] [-arch <arch>]* <inputs> [-o <output>]*
10-
CHECK: OPTIONS:
11-
CHECK: -help display this help
11+
; CHECK: OVERVIEW: LLVM TAPI file reader and transformer
12+
; CHECK: USAGE: llvm-readtapi <command> [-arch <architecture> <options>]* <inputs> [-o <output>]*
13+
; CHECK: COMMANDS:
14+
; CHECK: OPTIONS:
15+
; CHECK: -help display this help
1216

13-
MULTI_ACTION: error: only one of the following actions can be specified: -merge -compare
14-
FILE_FORMAT: error: deprecated filetype 'tbd-v2' is not supported to write
17+
; MULTI_ACTION: error: only one of the following actions can be specified: -merge -compare
18+
; FILE_FORMAT: error: deprecated filetype 'tbd-v2' is not supported to write
1519

20+
; VERSION: {{ version }}

llvm/tools/llvm-readtapi/TapiOpts.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ multiclass JS<string name, string help, string var = ""> {
1010
//
1111
// Top level operations
1212
//
13-
def action_group : OptionGroup<"action group">;
13+
def action_group : OptionGroup<"action group">, HelpText<"COMMANDS">;
1414
def compare : FF<"compare", "compare tapi files for library differences">, Group<action_group>;
1515
def merge : FF<"merge", "merge the input files that represent the same library">, Group<action_group>;
16-
def extract: FF<"extract", "extract architecture from input file">, Group<action_group>;
17-
def remove: FF<"remove", "remove architecture from input file">, Group<action_group>;
16+
def extract: FF<"extract", "extract <architecture> from input file">, Group<action_group>;
17+
def remove: FF<"remove", "remove <architecture> from input file">, Group<action_group>;
1818

1919
//
2020
// General Driver options
2121
//
2222
def help : FF<"help", "display this help">;
23+
def version: FF<"version", "print the llvm-readtapi version">;
24+
def v: FF<"v", "alias for --version">, Alias<version>;
2325
defm output: JS<"o", "write output to <file>","<file>">;
2426
def compact: FF<"compact", "write compact tapi output file">;
2527
defm filetype: JS<"filetype", "specify the output file type (tbd-v3, tbd-v4 or tbd-v5)","<value>">;
26-
defm arch: JS<"arch", "specify the architecture", "<architecture>">;
28+
defm arch: JS<"arch", "specify the <architecture>", "<architecture>">;

llvm/tools/llvm-readtapi/llvm-readtapi.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- llvm-readtapi.cpp - tapi file reader and manipulator -----*- C++-*-===//
1+
//===-- llvm-readtapi.cpp - tapi file reader and transformer -----*- C++-*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -171,9 +171,15 @@ int main(int Argc, char **Argv) {
171171
Argc, Argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) { reportError(Msg); });
172172
if (Args.hasArg(OPT_help)) {
173173
Tbl.printHelp(outs(),
174-
"USAGE: llvm-readtapi [options] [-arch <arch>]* <inputs> [-o "
174+
"USAGE: llvm-readtapi <command> [-arch <architecture> "
175+
"<options>]* <inputs> [-o "
175176
"<output>]*",
176-
"LLVM TAPI file reader and manipulator");
177+
"LLVM TAPI file reader and transformer");
178+
return EXIT_SUCCESS;
179+
}
180+
181+
if (Args.hasArg(OPT_version)) {
182+
cl::PrintVersionMessage();
177183
return EXIT_SUCCESS;
178184
}
179185

0 commit comments

Comments
 (0)