[Vala] [Genie] OptionContext not setting reference



Hey all,

I'm having a little trouble with this code:

[indent=4]

init
    args = args[1:args.length]
    try
        var options = new Options(args)

        if options.version
            print "0.0.1"
    except e : OptionError
        print e.message
    return


class Shellgtk.Options : Object
    prop readonly version : bool

    options : array of OptionEntry
    parser : OptionContext

    init
        _version = false

        options = new array of OptionEntry[2]
        options[0] = {
"version", 'v', OptionFlags.IN_MAIN, OptionArg.NONE, ref _version,
            "output version information and exit", null }
        options[1] = { null }

        parser = new OptionContext("")
        parser.add_main_entries(options, null)

    construct(args : array of string) raises OptionError
        parser.parse(ref args)

It compiles and runs but the option flag variable for version in the Options class is never set. I've tried to go through the generated C code and I can't find the problem. Any help is appreciated :-) .

Regards,

Chris





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]