After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 777020 - gnome-maps --version
gnome-maps --version
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
3.18.x
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
Depends on:
Blocks:
 
 
Reported: 2017-01-08 19:38 UTC by tobias
Modified: 2017-10-02 19:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add --version command line arguement (1.48 KB, patch)
2017-01-10 09:12 UTC, Anup Agarwal
none Details | Review
Add --version command line arguement (1.46 KB, patch)
2017-01-10 16:49 UTC, Anup Agarwal
needs-work Details | Review
application: Add --version command line arguement (1.57 KB, patch)
2017-10-02 19:53 UTC, Marcus Lundblad
committed Details | Review

Description tobias 2017-01-08 19:38:03 UTC
It would be nice to have a "gnome-maps --version" command line option.
Comment 1 Jonas Danielsson 2017-01-09 06:13:05 UTC
Marked as friendly bug for newcomers, should be easy enough to add.
Comment 2 Anup Agarwal 2017-01-09 11:00:29 UTC
I'd like to work on this
Comment 3 Marcus Lundblad 2017-01-09 22:20:21 UTC
(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.
Comment 4 Anup Agarwal 2017-01-10 09:12:55 UTC
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.
Comment 5 Jonas Danielsson 2017-01-10 13:00:32 UTC
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.
Comment 6 Jonas Danielsson 2017-01-10 13:00:41 UTC
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.
Comment 7 Anup Agarwal 2017-01-10 16:49:47 UTC
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
Comment 8 Jonas Danielsson 2017-01-11 07:07:16 UTC
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?
Comment 9 tobias 2017-01-11 07:46:31 UTC
Wow, that was fast. One addition, most Unix programs have [‑v] and [‑‑version] to show the version. Perhaps you can add the [‑v] too.
Comment 10 Jonas Danielsson 2017-01-11 08:24:44 UTC
(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'.
Comment 11 Marcus Lundblad 2017-01-11 08:29:39 UTC
(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?
Comment 12 Anup Agarwal 2017-01-11 15:03:57 UTC
(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.
Comment 13 Jonas Danielsson 2017-02-07 07:02:51 UTC
Thanks! Could you add a comment about this to the code?
Comment 14 Marcus Lundblad 2017-10-02 19:53:06 UTC
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
Comment 15 Marcus Lundblad 2017-10-02 19:55:03 UTC
Attachment 360802 [details] pushed as 93c08b3 - application: Add --version command line arguement