diff options
author | Aylur <[email protected]> | 2024-10-15 01:26:32 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-10-15 01:26:32 +0200 |
commit | 2f71cd4c08bb4514efe43533e6a5d03535204c29 (patch) | |
tree | fc991a12e159ad645187862c90f40731794d6e47 /core/src/cli.vala | |
parent | 9fab13452a26ed55c01047d4225f699f43bba20d (diff) |
refactor lua and gjs lib
Diffstat (limited to 'core/src/cli.vala')
-rw-r--r-- | core/src/cli.vala | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/core/src/cli.vala b/core/src/cli.vala deleted file mode 100644 index 0b60cd1..0000000 --- a/core/src/cli.vala +++ /dev/null @@ -1,87 +0,0 @@ -private static bool version; -private static bool help; -private static bool list; -private static bool quit; -private static bool inspector; -private static string? toggle_window; -private static string? instance_name; - -private const GLib.OptionEntry[] options = { - { "version", 'v', OptionFlags.NONE, OptionArg.NONE, ref version, null, null }, - { "help", 'h', OptionFlags.NONE, OptionArg.NONE, ref help, null, null }, - { "list", 'l', OptionFlags.NONE, OptionArg.NONE, ref list, null, null }, - { "quit", 'q', OptionFlags.NONE, OptionArg.NONE, ref quit, null, null }, - { "quit", 'q', OptionFlags.NONE, OptionArg.NONE, ref quit, null, null }, - { "inspector", 'I', OptionFlags.NONE, OptionArg.NONE, ref inspector, null, null }, - { "toggle-window", 't', OptionFlags.NONE, OptionArg.STRING, ref toggle_window, null, null }, - { "instance", 'i', OptionFlags.NONE, OptionArg.STRING, ref instance_name, null, null }, - { null }, -}; - -int main(string[] argv) { - try { - var opts = new OptionContext(); - opts.add_main_entries(options, null); - opts.set_help_enabled(false); - opts.set_ignore_unknown_options(false); - opts.parse(ref argv); - } catch (OptionError err) { - printerr (err.message); - return 1; - } - - if (help) { - print("Client for Astal.Application instances\n\n"); - print("Usage:\n"); - print(" %s [flags] message\n\n", argv[0]); - print("Flags:\n"); - print(" -h, --help Print this help and exit\n"); - print(" -v, --version Print version number and exit\n"); - print(" -l, --list List running Astal instances and exit\n"); - print(" -q, --quit Quit an Astal.Application instance\n"); - print(" -i, --instance Instance name of the Astal instance\n"); - print(" -I, --inspector Open up Gtk debug tool\n"); - print(" -t, --toggle-window Show or hide a window\n"); - return 0; - } - - if (version) { - print(Astal.VERSION); - return 0; - } - - if (instance_name == null) - instance_name = "astal"; - - if (list) { - foreach (var name in Astal.Application.get_instances()) - stdout.printf("%s\n", name); - - return 0; - } - - if (quit) { - Astal.Application.quit_instance(instance_name); - return 0; - } - - if (inspector) { - Astal.Application.open_inspector(instance_name); - return 0; - } - - if (toggle_window != null) { - Astal.Application.toggle_window_by_name(instance_name, toggle_window); - return 0; - } - - var request = ""; - for (var i = 1; i < argv.length; ++i) { - request = request.concat(" ", argv[i]); - } - - var reply = Astal.Application.send_message(instance_name, request); - print("%s\n", reply); - - return 0; -} |