spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit c32bcadde19ed5803a576849d9ff50aa4e918ae0
parent 3b48f7cbe24cf990d86585d3433d925002cf5137
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Mon, 17 May 2010 17:10:29 +1000

Parse command line options, print version info

Diffstat:
Msrc/spek.vala | 22+++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/spek.vala b/src/spek.vala @@ -18,12 +18,32 @@ using Spek; +bool version = false; +// TODO: move into main() when bgo#530623 is fixed. +const OptionEntry[] options = { + { "version", 'V', 0, OptionArg.NONE, &version, N_("Display the version and exit"), null }, + { null } +}; + int main (string[] args) { Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR); Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8"); Intl.textdomain (Config.GETTEXT_PACKAGE); - Gtk.init (ref args); + try { + Gtk.init_with_args (ref args, _("[FILE]"), (OptionEntry[]) options, Config.GETTEXT_PACKAGE); + } catch (Error e) { + print (e.message); + print ("\n"); + print (_("Run `%s --help` to see a full list of available command line options.\n"), args[0]); + return 1; + } + + if (version) { + print (_("%s version %s\n"), Config.PACKAGE_NAME, Config.PACKAGE_VERSION); + return 0; + } + Gst.init (ref args); var window = new Window (); Gtk.main ();