Closed GoogleCodeExporter closed 9 years ago
Not able to reproduce with 1.0.4pre.
Original comment by kate.war...@gtempaccount.com
on 28 Mar 2010 at 11:24
Hi, using version 1.0.4pre I get this same error when I run ./myscript -h
With this definition:
DEFINE_integer 'port' '' 'Port to change adapter to use' 'p'
flags:ERROR invalid flag name (__flags_port_default)
-p,--port: Port to change adapter to use (default: )
This is right above the normal expected output.
Original comment by BostonVaulter
on 23 Jul 2010 at 4:19
It looks like we may need to handle the case of an integer with a blank (empty
string) for the default value separately. Here is a patch that will allow you
to set any integers without a default value to a default value of -9000. The
best way to handle this may be to make some way to easily check if a flag was
passed to the program. This would help in adding required flags, but that might
be good to have in shflags itself.
Author: Jason Axelson <jason.axelson@gmail.com>
Date: Thu Jul 22 18:52:24 2010 -1000
Semi-fixed bug not allowing integers to not specify a default
--- a/shflags-1.04pre
+++ b/shflags-1.04pre
@@ -414,8 +414,14 @@ _flags_getFlagInfo()
if [ "${_flags_typeValue_}" = "${__FLAGS_TYPE_STRING}" ]; then
flags_return=${FLAGS_TRUE}
else
- flags_return=${FLAGS_ERROR}
- flags_error="invalid flag name (${_flags_nameVar_})"
+ if [ "${_flags_typeValue_}" = "${__FLAGS_TYPE_INTEGER}" ]; then
+ echo "This is an integer that didn't provide a default value" >&2;
+ _flags_nameValue_=-9000; # Some default value
+ flags_return=${FLAGS_TRUE}
+ else
+ flags_return=${FLAGS_ERROR}
+ flags_error="invalid flag name (${_flags_nameVar_})"
+ fi
fi
fi
Original comment by BostonVaulter
on 23 Jul 2010 at 4:57
Original issue reported on code.google.com by
kate.war...@gtempaccount.com
on 24 Nov 2008 at 4:39