Codebase list gnome-maps / b5e833e
application: Add command line option for search Adds a -S command line option as an alternative to initialize a search query. Equivalent to using the maps: URI scheme. Marcus Lundblad 2 years ago
1 changed file(s) with 20 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
124124 GLib.OptionArg.NONE,
125125 _("Ignore network availability"),
126126 null);
127
128 this.add_main_option('search',
129 'S'.charCodeAt(0),
130 GLib.OptionFlags.NONE,
131 GLib.OptionArg.STRING,
132 _("Search for places"),
133 null);
134
127135 /* due to https://gitlab.gnome.org/GNOME/gjs/-/issues/330 the
128136 * description for the remaining args needs to be passed as both
129137 * description and arg_description
424432 }
425433
426434 let remaining = options.lookup(GLib.OPTION_REMAINING, null);
435 let files = [];
436
437 // when given the search CLI argument, insert URI as first file
438 if (options.contains('search')) {
439 let query = options.lookup_value('search', null).deep_unpack();
440
441 files = [Gio.File.new_for_uri(`maps:q=${query}`)];
442 }
427443
428444 if (remaining) {
429 let files = [];
430
431445 remaining.forEach((r) => {
432446 let path = r.get_string()[0];
433447
438452 files.push(Gio.File.new_for_path(path));
439453 }
440454 });
441
455 }
456
457 if (files.length > 0)
442458 this.open(files, '');
443 } else {
459 else
444460 this.activate();
445 }
446461
447462 return 0;
448463 }