Open AntonioCS opened 4 years ago
I see this which looks wrong [-ho <file>]
... is that causing the problem?
I don't know. The error message is just the generic: params are not right..
What is wrong exactly? I want to be able to pass a file either by doing -o
I also want it to be mandatory that if you pass -o or --output that you pass
To note if I do this:
my_program -o file path
I get the following error:
Unexpected argument: -o, file, path
I also get an error with --output=file
I have tried:
- -o <file> --output=<file> specify output file [default: ./default.h]
- -o file --output=file specify output file [default: ./default.h]
- -o --output=file specify output file [default: ./default.h]
Is what I want impossible?
What you’re trying to do is not impossible. You just haven’t got the syntax quite right. Try this:
Usage:
my_program [--output=<file>]
Options:
-o, --output <file> specify output file [default: ./default.h]
I encourage you to play around with this online tool. It’s great for prototyping.
@Kerndog73 So following your suggestion I have changed it to:
static const char USAGE[] =
R"(Usage: my_program [-h] [--output=<file>] [--remove_comments] [--no_separators] [--no_timestamp] [--silent] [path]
Arguments:
[path] path to directory of header files
Options:
-h --help show this
-o, --output <file> specify output file [default: ./default.h]
--remove_comments remove one line comments from the header files
--no_separators don't add // <filename> START|END separators
--no_timestamp don't add timestamp
--silent no info text
)";
Added Arguments
and Options
section.
I calling the program like:
my_program --output=file path
Still getting the same error:
Unexpected argument: --ouput=file, path
Usage: onlyoneheader [-h] [--output=<file>] [--remove_comments] [--no_separators] .........
That’s because file path
is two separate arguments. You need to use a backslash. file\ path
.
Not sure if I follow you.. but I did
my_program --ouput=file\ path
and got:
Unexpected argument: --ouput=file\, path
Not exactly sure why this is breaking now... I mean.. this at least worked before with just --output=file path
(when I removed the -o stuff) and now it's breaking...
Is there a way to get some better error messages? Like -vvv for errors?
You spelled it ouput
in the example you typed (missing a 't'). Does that fix it?
No, the errors are not helpful and would be super helpful (but super hard :( ) .. there is an Issue open fort hat.
@jaredgrubb this is what I get for trying to program late at night! That was indeed the issue. So to provide full context here is what I have currently:
static const char USAGE[] =
R"(Usage: my_program [-h] [--output=<file>] [--remove_comments] [--no_separators] [--no_timestamp] [--silent] <path>
Arguments:
<path> path to directory of header files
Options:
-h --help show this
-o --output=<file> specify output file [default: ./default.h]
--remove_comments remove one line comments from the header files
--no_separators don't add // <filename> START|END separators
--no_timestamp don't add timestamp
--silent no info text
)";
Now the -o is not longer a boolean option and everything works.
One thing I would like to know is if it's possible to add back the -o
to the Usage
part or does it only have to show up in the Options
like I guess the --help
does?
Possibly also add a few more examples that have this exact scenario? Found some examples that were similar but don't think they were exactly like what I had.
Thanks @jaredgrubb , @Kerndog73. for helping me with this, was really going crazy.
I have the following:
I then call
my_program
:my_program.exe --output=test ./dir/
this gives me an error ofArguments did not match expected patterns
If I remove the
-o <file>
so thatUSAGE
becomes:All works as expected. Shouldn't the
-o <file>
work?