output help by default

This commit is contained in:
anon 2024-04-11 14:15:08 +02:00
parent 4a1385d9ce
commit e7772a7511
3 changed files with 18 additions and 1 deletions

View File

@ -11,6 +11,7 @@
extern std::stack<std::string> tag_stack;
const char * const csml_extension = ".csml";
bool did_any_work = false;
static
const char * const version =
@ -72,6 +73,11 @@ void yylex(FILE * &yyin, FILE * &yyout, int (*yylex_)(void)) {
}
// ### global functions ###
extern "C"
void usage(void) {
fputs(help_message, stdout);
}
extern "C"
signed parse_round1_arguments(int argc, char * * argv){
const char * const optstring = "-" "hv" "cxs:S:i:o:q:";
@ -86,7 +92,7 @@ signed parse_round1_arguments(int argc, char * * argv){
while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
switch (opt) {
case 'h': {
fputs(help_message, stdout);
usage();
} return EXIT_EARLY_SUCCESS;
case 'v': {
fputs(version, stdout);
@ -124,6 +130,7 @@ signed parse_round2_arguments(int argc, char * * argv) {
++n;
output = argv[n];
} else {
did_any_work = true;
input = argv[n];
if (input_type == input_type_t::AUTO_DETECT) {

View File

@ -3,6 +3,12 @@
#include <vector>
#include <string>
/* Used for outputting a help message as the default behaviour
*/
extern bool did_any_work;
extern "C" void usage(void);
extern "C" signed parse_colon_list(char * const list, std::vector<std::string> destination);
extern "C" signed parse_sets(char * const list);

View File

@ -83,6 +83,10 @@ signed main(int argc, char * * argv) {
parse_round2_arguments(argc - 1, argv + 1);
if (not did_any_work) {
usage();
}
xml_lex_destroy();
csml_lex_destroy();