GNOME Bugzilla – Bug 777020
gnome-maps --version
Last modified: 2017-10-02 19:55:07 UTC
It would be nice to have a "gnome-maps --version" command line option.
Marked as friendly bug for newcomers, should be easy enough to add.
I'd like to work on this
(In reply to Anup Agarwal from comment #2) > I'd like to work on this A good place to look might gnome-documents, I think, since it's also written in JS and honors the --version option.
Created attachment 343223 [details] [review] Add --version command line arguement This commit address the bug: https://bugzilla.gnome.org/show_bug.cgi?id=777020 In this bug a need for a --version command line arguement was raised.
Review of attachment 343223 [details] [review]: Thanks! ::: src/application.js @@ -282,2 +285,3 @@ }, + vfunc_handle_local_options: function(options) { I think this could be handled in the same 'handle-local-options' signal handler as above, where the 'local' options is handled.
Created attachment 343259 [details] [review] Add --version command line arguement This commit address the bug: https://bugzilla.gnome.org/show_bug.cgi?id=777020 In this bug a need for a --version command line arguement was raised. The version flag is handled in the same location where the local flag is handled i.e.'handle-local-options' signal handler
Review of attachment 343259 [details] [review]: Thanks! ::: src/application.js @@ -107,2 +110,5 @@ this.local_tile_path = variant.deep_unpack(); normalStartup = false; + } else if (options.contains('version')) { + print(pkg.version); + return 0; What happens when we return 0 and not -1? The program(instance) terminates? Could we get some comment about it? What happens when a Maps window is already running and you go gnome-maps --version in the terminal?
Wow, that was fast. One addition, most Unix programs have [‑v] and [‑‑version] to show the version. Perhaps you can add the [‑v] too.
(In reply to tobias from comment #9) > Wow, that was fast. One addition, most Unix programs have [‑v] and > [‑‑version] to show the version. Perhaps you can add the [‑v] too. Looking at the patch I think this is already the cacse, it adds both 'version' and 'v'.charAt(0) which will be the ascii value for 'v'.
(In reply to Jonas Danielsson from comment #8) > Review of attachment 343259 [details] [review] [review]: > > Thanks! > > ::: src/application.js > @@ -107,2 +110,5 @@ > this.local_tile_path = variant.deep_unpack(); > normalStartup = false; > + } else if (options.contains('version')) { > + print(pkg.version); > + return 0; > > What happens when we return 0 and not -1? The program(instance) terminates? > Could we get some comment about it? Yes, -1 means "continue execution", and >=0 return using the UNIX exit code as given (0 is success and >0 is interpreted as an error code typically). > > What happens when a Maps window is already running and you go gnome-maps > --version in the terminal?
(In reply to Jonas Danielsson from comment #8) > Review of attachment 343259 [details] [review] [review]: > > Thanks! > > ::: src/application.js > @@ -107,2 +110,5 @@ > this.local_tile_path = variant.deep_unpack(); > normalStartup = false; > + } else if (options.contains('version')) { > + print(pkg.version); > + return 0; > > What happens when we return 0 and not -1? The program(instance) terminates? > Could we get some comment about it? Referring to: https://developer.gnome.org/gio/2.42/GApplication.html#GApplication-handle-local-options The handler returns an exit code. If you have handled your options and want to exit the process, return a non-negative option, 0 for success, and a positive value for failure. To continue, return -1 to let the default option processing continue. So if we are unable to handle options we return -1. Also, I think for the local options since further processing needs to be done i.e. the mapView needs to launched with local tiles directory structure, thus -1 seems to be appropriate. In the case of version since no other processing needs to be done thus 0 conforms with the exit code convention/requirement. > > What happens when a Maps window is already running and you go gnome-maps > --version in the terminal? In such an event, the version of the package is printed in that particular terminal and the original Maps window is unaffected.
Thanks! Could you add a comment about this to the code?
Created attachment 360802 [details] [review] application: Add --version command line arguement Adds a --version command line option. The version flag is handled in the same location where the local flag is handled i.e.'handle-local-options' signal handler
Attachment 360802 [details] pushed as 93c08b3 - application: Add --version command line arguement