An option arg of type G_OPTION_ARG_INT and of value 0 is ignored.
When using GApplication, an option arg of type G_OPTION_ARG_INT and of value 0 is ignored.
Here is a python test code, test_application_option.py.
import sys
from gi.repository import GLib, Gio
class App(Gio.Application):
def __init__(self):
super().__init__(flags = Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
self.add_main_option('int', 0, GLib.OptionFlags.NONE, GLib.OptionArg.INT, '', None)
def do_command_line(self, cmd):
print(cmd.get_options_dict().end().unpack())
return 0
App().run(sys.argv)
Here is the test output.
$ python3 test_application_option.py --int 4
{'int': 4}
$ python3 test_application_option.py --int 0
{}
I analyzed the source of g_application_pack_option_entries().
...
case G_OPTION_ARG_INT:
if (*(gint32 *) entry->arg_data)
value = g_variant_new_int32 (*(gint32 *) entry->arg_data);
break;
...
The if condition on *(gint32 *)entry->arg_data should be removed, because *(gint32 *)entry->arg_data will be 0 normally if the argument is '0'.
Edited by Myoung-serp Shin