Skip to content

Commit

Permalink
Add a terminate_ater_init command line option
Browse files Browse the repository at this point in the history
You can use this to measure Junction startup time with

> time flatpak run re.sonny.Junction --terminate_after_init

"terminate_after_init" is the argument name from Libreoffice
  • Loading branch information
sonnyp committed Dec 20, 2021
1 parent 1d31e34 commit 0fe6718
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Gio from "gi://Gio";
import Adw from "gi://Adw";
import GLib from "gi://GLib";

import Window from "./window.js";
import Welcome from "./welcome.js";
Expand Down Expand Up @@ -44,6 +45,22 @@ export default function Application({ version, datadir }) {
loadStyleSheet(relativePath("./style.css"));
});

application.connect("handle-local-options", (self, options) => {
return options.contains("terminate_after_init") ? 0 : -1;
});

// This shouldn't be in the main options but rather in a "Development" group
// unfortunally - I couldn't use OptionGroup
// https://gitlab.gnome.org/GNOME/gjs/-/issues/448
application.add_main_option(
"terminate_after_init",
null,
GLib.OptionFlags.NONE,
GLib.OptionArg.NONE,
"Exit after initialization complete",
null,
);

application.set_option_context_description("<https://junction.sonny.re>");
application.set_option_context_parameter_string("[URI…]");
// TODO: Add examples
Expand Down

0 comments on commit 0fe6718

Please sign in to comment.