@@ -633,9 +633,18 @@ void version() {
633
633
}
634
634
635
635
/* *
636
- * Diplays the usage message and then exits with an error code.
636
+ * Display the usage message and then exit with an error code.
637
637
*/
638
638
void usage () {
639
+ fprintf (stderr, " Usage: thrift [options] file\n\n " );
640
+ fprintf (stderr, " Use thrift -help for a list of options\n " );
641
+ exit (1 );
642
+ }
643
+
644
+ /* *
645
+ * Diplays the help message and then exits with an error code.
646
+ */
647
+ void help () {
639
648
fprintf (stderr, " Usage: thrift [options] file\n " );
640
649
fprintf (stderr, " Options:\n " );
641
650
fprintf (stderr, " -version Print the compiler version\n " );
@@ -971,7 +980,9 @@ int main(int argc, char** argv) {
971
980
++arg;
972
981
}
973
982
974
- if (strcmp (arg, " -version" ) == 0 ) {
983
+ if (strcmp (arg, " -help" ) == 0 ) {
984
+ help ();
985
+ } else if (strcmp (arg, " -version" ) == 0 ) {
975
986
version ();
976
987
exit (1 );
977
988
} else if (strcmp (arg, " -debug" ) == 0 ) {
@@ -992,7 +1003,7 @@ int main(int argc, char** argv) {
992
1003
} else if (strcmp (arg, " -gen" ) == 0 ) {
993
1004
arg = argv[++i];
994
1005
if (arg == NULL ) {
995
- fprintf (stderr, " !!! Missing generator specification\n " );
1006
+ fprintf (stderr, " Missing generator specification\n " );
996
1007
usage ();
997
1008
}
998
1009
generator_strings.push_back (arg);
@@ -1055,7 +1066,7 @@ int main(int argc, char** argv) {
1055
1066
arg = argv[++i];
1056
1067
1057
1068
if (arg == NULL ) {
1058
- fprintf (stderr, " !!! Missing Include directory\n " );
1069
+ fprintf (stderr, " Missing Include directory\n " );
1059
1070
usage ();
1060
1071
}
1061
1072
g_incl_searchpath.push_back (arg);
@@ -1088,7 +1099,7 @@ int main(int argc, char** argv) {
1088
1099
return -1 ;
1089
1100
}
1090
1101
} else {
1091
- fprintf (stderr, " !!! Unrecognized option: %s\n " , arg);
1102
+ fprintf (stderr, " Unrecognized option: %s\n " , arg);
1092
1103
usage ();
1093
1104
}
1094
1105
@@ -1097,103 +1108,27 @@ int main(int argc, char** argv) {
1097
1108
}
1098
1109
}
1099
1110
1111
+ // display help
1112
+ if ((strcmp (argv[argc-1 ], " -help" ) == 0 ) || (strcmp (argv[argc-1 ], " --help" ) == 0 )) {
1113
+ help ();
1114
+ }
1115
+
1100
1116
// if you're asking for version, you have a right not to pass a file
1101
- if (strcmp (argv[argc-1 ], " -version" ) == 0 ) {
1117
+ if (( strcmp (argv[argc-1 ], " -version" ) == 0 ) || ( strcmp (argv[argc- 1 ], " --version " ) == 0 ) ) {
1102
1118
version ();
1103
1119
exit (1 );
1104
1120
}
1105
1121
1106
- // TODO(dreiss): Delete these when everyone is using the new hotness.
1107
- if (gen_cpp) {
1108
- pwarning (1 , " -cpp is deprecated. Use --gen cpp" );
1109
- string gen_string = " cpp:" ;
1110
- if (gen_dense) {
1111
- gen_string.append (" dense," );
1112
- }
1113
- if (g_cpp_use_include_prefix) {
1114
- gen_string.append (" include_prefix," );
1115
- }
1116
- generator_strings.push_back (gen_string);
1117
- }
1118
- if (gen_java) {
1119
- pwarning (1 , " -java is deprecated. Use --gen java" );
1120
- generator_strings.push_back (" java" );
1121
- }
1122
- if (gen_javabean) {
1123
- pwarning (1 , " -javabean is deprecated. Use --gen java:beans" );
1124
- generator_strings.push_back (" java:beans" );
1125
- }
1126
- if (gen_csharp) {
1127
- pwarning (1 , " -csharp is deprecated. Use --gen csharp" );
1128
- generator_strings.push_back (" csharp" );
1129
- }
1130
- if (gen_delphi) {
1131
- pwarning (1 , " -delphi is deprecated. Use --gen delphi" );
1132
- generator_strings.push_back (" delphi" );
1133
- }
1134
- if (gen_py) {
1135
- pwarning (1 , " -py is deprecated. Use --gen py" );
1136
- generator_strings.push_back (" py" );
1137
- }
1138
- if (gen_rb) {
1139
- pwarning (1 , " -rb is deprecated. Use --gen rb" );
1140
- generator_strings.push_back (" rb" );
1141
- }
1142
- if (gen_perl) {
1143
- pwarning (1 , " -perl is deprecated. Use --gen perl" );
1144
- generator_strings.push_back (" perl" );
1145
- }
1146
- if (gen_php || gen_phpi) {
1147
- pwarning (1 , " -php is deprecated. Use --gen php" );
1148
- string gen_string = " php:" ;
1149
- if (gen_phpi) {
1150
- gen_string.append (" inlined," );
1151
- } else if (gen_phps) {
1152
- gen_string.append (" server," );
1153
- } else if (gen_phpa) {
1154
- gen_string.append (" autoload," );
1155
- } else if (gen_phpo) {
1156
- gen_string.append (" oop," );
1157
- } else if (gen_rest) {
1158
- gen_string.append (" rest," );
1159
- }
1160
- generator_strings.push_back (gen_string);
1161
- }
1162
- if (gen_cocoa) {
1163
- pwarning (1 , " -cocoa is deprecated. Use --gen cocoa" );
1164
- generator_strings.push_back (" cocoa" );
1165
- }
1166
- if (gen_erl) {
1167
- pwarning (1 , " -erl is deprecated. Use --gen erl" );
1168
- generator_strings.push_back (" erl" );
1169
- }
1170
- if (gen_st) {
1171
- pwarning (1 , " -st is deprecated. Use --gen st" );
1172
- generator_strings.push_back (" st" );
1173
- }
1174
- if (gen_ocaml) {
1175
- pwarning (1 , " -ocaml is deprecated. Use --gen ocaml" );
1176
- generator_strings.push_back (" ocaml" );
1177
- }
1178
- if (gen_hs) {
1179
- pwarning (1 , " -hs is deprecated. Use --gen hs" );
1180
- generator_strings.push_back (" hs" );
1181
- }
1182
- if (gen_xsd) {
1183
- pwarning (1 , " -xsd is deprecated. Use --gen xsd" );
1184
- generator_strings.push_back (" xsd" );
1185
- }
1186
-
1187
1122
// You gotta generate something!
1188
1123
if (generator_strings.empty ()) {
1189
- fprintf (stderr, " !!! No output language(s) specified\n \n" );
1124
+ fprintf (stderr, " No output language(s) specified\n " );
1190
1125
usage ();
1191
1126
}
1192
1127
1193
1128
// Real-pathify it
1194
1129
char rp[PATH_MAX];
1195
1130
if (argv[i] == NULL ) {
1196
- fprintf (stderr, " !!! Missing file name\n " );
1131
+ fprintf (stderr, " Missing file name\n " );
1197
1132
usage ();
1198
1133
}
1199
1134
if (saferealpath (argv[i], rp) == NULL ) {
0 commit comments