mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Make CommandLine prefix error output with the name of the program.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16129 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d808bcaefe
commit
e1cc150a8e
@ -29,6 +29,10 @@ using namespace llvm;
|
|||||||
|
|
||||||
using namespace cl;
|
using namespace cl;
|
||||||
|
|
||||||
|
// Globals for name and overview of program
|
||||||
|
static const char *ProgramName = "<unknown>";
|
||||||
|
static const char *ProgramOverview = 0;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Basic, shared command line option processing machinery...
|
// Basic, shared command line option processing machinery...
|
||||||
//
|
//
|
||||||
@ -57,8 +61,8 @@ static std::vector<Option*> &getPositionalOpts() {
|
|||||||
|
|
||||||
static void AddArgument(const char *ArgName, Option *Opt) {
|
static void AddArgument(const char *ArgName, Option *Opt) {
|
||||||
if (getOption(ArgName)) {
|
if (getOption(ArgName)) {
|
||||||
std::cerr << "CommandLine Error: Argument '" << ArgName
|
std::cerr << ProgramName << ": CommandLine Error: Argument '"
|
||||||
<< "' defined more than once!\n";
|
<< ArgName << "' defined more than once!\n";
|
||||||
} else {
|
} else {
|
||||||
// Add argument to the argument map!
|
// Add argument to the argument map!
|
||||||
getOpts()[ArgName] = Opt;
|
getOpts()[ArgName] = Opt;
|
||||||
@ -83,9 +87,6 @@ static void RemoveArgument(const char *ArgName, Option *Opt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *ProgramName = 0;
|
|
||||||
static const char *ProgramOverview = 0;
|
|
||||||
|
|
||||||
static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
||||||
const char *Value, int argc, char **argv,
|
const char *Value, int argc, char **argv,
|
||||||
int &i) {
|
int &i) {
|
||||||
@ -105,9 +106,14 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
return Handler->error(" does not allow a value! '" +
|
return Handler->error(" does not allow a value! '" +
|
||||||
std::string(Value) + "' specified.");
|
std::string(Value) + "' specified.");
|
||||||
break;
|
break;
|
||||||
case ValueOptional: break;
|
case ValueOptional:
|
||||||
default: std::cerr << "Bad ValueMask flag! CommandLine usage error:"
|
break;
|
||||||
<< Handler->getValueExpectedFlag() << "\n"; abort();
|
default:
|
||||||
|
std::cerr << ProgramName
|
||||||
|
<< ": Bad ValueMask flag! CommandLine usage error:"
|
||||||
|
<< Handler->getValueExpectedFlag() << "\n";
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the handler now!
|
// Run the handler now!
|
||||||
@ -432,8 +438,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Handler == 0) {
|
if (Handler == 0) {
|
||||||
std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: '"
|
std::cerr << ProgramName << ": Unknown command line argument '" << argv[i]
|
||||||
<< argv[0] << " --help'\n";
|
<< "'. Try: '" << argv[0] << " --help'\n";
|
||||||
ErrorParsing = true;
|
ErrorParsing = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -469,7 +475,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
|
|
||||||
// Check and handle positional arguments now...
|
// Check and handle positional arguments now...
|
||||||
if (NumPositionalRequired > PositionalVals.size()) {
|
if (NumPositionalRequired > PositionalVals.size()) {
|
||||||
std::cerr << "Not enough positional command line arguments specified!\n"
|
std::cerr << ProgramName
|
||||||
|
<< ": Not enough positional command line arguments specified!\n"
|
||||||
<< "Must specify at least " << NumPositionalRequired
|
<< "Must specify at least " << NumPositionalRequired
|
||||||
<< " positional arguments: See: " << argv[0] << " --help\n";
|
<< " positional arguments: See: " << argv[0] << " --help\n";
|
||||||
ErrorParsing = true;
|
ErrorParsing = true;
|
||||||
@ -575,8 +582,8 @@ bool Option::error(std::string Message, const char *ArgName) {
|
|||||||
if (ArgName[0] == 0)
|
if (ArgName[0] == 0)
|
||||||
std::cerr << HelpStr; // Be nice for positional arguments
|
std::cerr << HelpStr; // Be nice for positional arguments
|
||||||
else
|
else
|
||||||
std::cerr << "-" << ArgName;
|
std::cerr << ProgramName << ": for the -" << ArgName;
|
||||||
std::cerr << " option" << Message << "\n";
|
std::cerr << " option: " << Message << "\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user