Skip to content

Commit

Permalink
[readtapi] Cleanup printing command line options (llvm#75106)
Browse files Browse the repository at this point in the history
Also, add a version option.
  • Loading branch information
cyndyishida authored Dec 12, 2023
1 parent 2a1d222 commit 142e567
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
17 changes: 11 additions & 6 deletions llvm/test/tools/llvm-readtapi/command-line.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
; RUN: not llvm-readtapi -merge -compare -compact %t/tmp.tbd %t/tmp2.tbd 2>&1 | FileCheck %s --check-prefix MULTI_ACTION
// Check unsupported file output format.
; RUN: not llvm-readtapi -merge -compact %t/tmp.tbd %t/tmp2.tbd --filetype=tbd-v2 2>&1 | FileCheck %s --check-prefix FILE_FORMAT
// Check version printing.
; RUN: llvm-readtapi -v 2>&1 | FileCheck %s --check-prefix VERSION
; RUN: llvm-readtapi --version 2>&1 | FileCheck %s --check-prefix VERSION

CHECK: OVERVIEW: LLVM TAPI file reader and manipulator
CHECK: USAGE: llvm-readtapi [options] [-arch <arch>]* <inputs> [-o <output>]*
CHECK: OPTIONS:
CHECK: -help display this help
; CHECK: OVERVIEW: LLVM TAPI file reader and transformer
; CHECK: USAGE: llvm-readtapi <command> [-arch <architecture> <options>]* <inputs> [-o <output>]*
; CHECK: COMMANDS:
; CHECK: OPTIONS:
; CHECK: -help display this help

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

; VERSION: {{ version }}
10 changes: 6 additions & 4 deletions llvm/tools/llvm-readtapi/TapiOpts.td
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ multiclass JS<string name, string help, string var = ""> {
//
// Top level operations
//
def action_group : OptionGroup<"action group">;
def action_group : OptionGroup<"action group">, HelpText<"COMMANDS">;
def compare : FF<"compare", "compare tapi files for library differences">, Group<action_group>;
def merge : FF<"merge", "merge the input files that represent the same library">, Group<action_group>;
def extract: FF<"extract", "extract architecture from input file">, Group<action_group>;
def remove: FF<"remove", "remove architecture from input file">, Group<action_group>;
def extract: FF<"extract", "extract <architecture> from input file">, Group<action_group>;
def remove: FF<"remove", "remove <architecture> from input file">, Group<action_group>;

//
// General Driver options
//
def help : FF<"help", "display this help">;
def version: FF<"version", "print the llvm-readtapi version">;
def v: FF<"v", "alias for --version">, Alias<version>;
defm output: JS<"o", "write output to <file>","<file>">;
def compact: FF<"compact", "write compact tapi output file">;
defm filetype: JS<"filetype", "specify the output file type (tbd-v3, tbd-v4 or tbd-v5)","<value>">;
defm arch: JS<"arch", "specify the architecture", "<architecture>">;
defm arch: JS<"arch", "specify the <architecture>", "<architecture>">;
12 changes: 9 additions & 3 deletions llvm/tools/llvm-readtapi/llvm-readtapi.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- llvm-readtapi.cpp - tapi file reader and manipulator -----*- C++-*-===//
//===-- llvm-readtapi.cpp - tapi file reader and transformer -----*- C++-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down Expand Up @@ -171,9 +171,15 @@ int main(int Argc, char **Argv) {
Argc, Argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) { reportError(Msg); });
if (Args.hasArg(OPT_help)) {
Tbl.printHelp(outs(),
"USAGE: llvm-readtapi [options] [-arch <arch>]* <inputs> [-o "
"USAGE: llvm-readtapi <command> [-arch <architecture> "
"<options>]* <inputs> [-o "
"<output>]*",
"LLVM TAPI file reader and manipulator");
"LLVM TAPI file reader and transformer");
return EXIT_SUCCESS;
}

if (Args.hasArg(OPT_version)) {
cl::PrintVersionMessage();
return EXIT_SUCCESS;
}

Expand Down

0 comments on commit 142e567

Please sign in to comment.