summaryrefslogtreecommitdiff
path: root/cpp/src/slice2freezej/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2freezej/Main.cpp')
-rw-r--r--cpp/src/slice2freezej/Main.cpp87
1 files changed, 75 insertions, 12 deletions
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index 02543702fe6..bcfcccbb095 100644
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -1417,6 +1417,7 @@ usage(const char* n)
"Options:\n"
"-h, --help Show this message.\n"
"-v, --version Display the Ice version.\n"
+ "--validate Validate command line options.\n"
"-DNAME Define NAME as 1.\n"
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
@@ -1459,6 +1460,7 @@ compile(int argc, char* argv[])
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
+ opts.addOpt("", "validate");
opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
@@ -1476,6 +1478,16 @@ compile(int argc, char* argv[])
opts.addOpt("", "underscore");
opts.addOpt("", "meta", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
+ bool validate = false;
+ for(int i = 0; i < argc; ++i)
+ {
+ if(string(argv[i]) == "--validate")
+ {
+ validate = true;
+ break;
+ }
+ }
+
vector<string> args;
try
{
@@ -1484,7 +1496,10 @@ compile(int argc, char* argv[])
catch(const IceUtilInternal::BadOptException& e)
{
getErrorStream() << argv[0] << ": error: " << e.reason << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
@@ -1549,21 +1564,30 @@ compile(int argc, char* argv[])
if(dict.name.empty())
{
getErrorStream() << argv[0] << ": error: " << *i << ": no name specified" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
if(dict.key.empty())
{
getErrorStream() << argv[0] << ": error: " << *i << ": no key specified" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
if(dict.value.empty())
{
getErrorStream() << argv[0] << ": error: " << *i << ": no value specified" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
@@ -1608,21 +1632,30 @@ compile(int argc, char* argv[])
if(index.name.empty())
{
getErrorStream() << argv[0] << ": error: " << *i << ": no name specified" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
if(index.type.empty())
{
getErrorStream() << argv[0] << ": error: " << *i << ": no type specified" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
if(index.member.empty())
{
getErrorStream() << argv[0] << ": error: " << *i << ": no member specified" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
@@ -1630,7 +1663,10 @@ compile(int argc, char* argv[])
{
getErrorStream() << argv[0] << ": error: " << *i << ": the case can be `case-sensitive' or "
<< "`case-insensitive'" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
index.caseSensitive = (caseString == "case-sensitive");
@@ -1683,7 +1719,10 @@ compile(int argc, char* argv[])
if(dictName.empty())
{
getErrorStream() << argv[0] << ": error: " << *i << ": no dictionary specified" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
@@ -1691,7 +1730,10 @@ compile(int argc, char* argv[])
{
getErrorStream() << argv[0] << ": error: " << *i << ": the case can be `case-sensitive' or "
<< "`case-insensitive'" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
index.caseSensitive = (caseString == "case-sensitive");
@@ -1716,7 +1758,10 @@ compile(int argc, char* argv[])
if(!found)
{
getErrorStream() << argv[0] << ": error: " << *i << ": unknown dictionary" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
}
@@ -1742,10 +1787,28 @@ compile(int argc, char* argv[])
if(dicts.empty() && indices.empty() && !(depend || dependxml))
{
getErrorStream() << argv[0] << ": error: no Freeze types specified" << endl;
- usage(argv[0]);
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
return EXIT_FAILURE;
}
+ if(depend && dependxml)
+ {
+ getErrorStream() << argv[0] << ": error: cannot specify both --depend and --depend-xml" << endl;
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
+ return EXIT_FAILURE;
+ }
+
+ if(validate)
+ {
+ return EXIT_SUCCESS;
+ }
+
UnitPtr u = Unit::createUnit(true, false, ice, underscore, globalMetadata);
int status = EXIT_SUCCESS;