From b92213f08de5c822889f2959fade9883834c24e7 Mon Sep 17 00:00:00 2001
From: Benjamin Koch <snowball@c3pb.de>
Date: Mon, 14 Dec 2020 02:36:11 +0100
Subject: [PATCH] Add `qubes` command to CLI

---
 src/QBar/Cli.hs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/QBar/Cli.hs b/src/QBar/Cli.hs
index 562f74b..41bf8d1 100644
--- a/src/QBar/Cli.hs
+++ b/src/QBar/Cli.hs
@@ -8,6 +8,7 @@ import QBar.ControlSocket
 import QBar.Core
 import QBar.DefaultConfig
 import QBar.Server
+import QBar.Qubes.AdminAPI (printEvents, qubesVMStats, qubesEvents)
 import QBar.Theme
 import QBar.Time
 
@@ -43,7 +44,8 @@ barCommandParser = hsubparser (
     command "server" (info serverCommandParser (progDesc "Start a new server.")) <>
     command "mirror" (info mirrorCommandParser (progDesc "Mirror the output of a running server.")) <>
     command "pipe" (info pipeClientParser (progDesc "Redirects the stdin of this process to a running bar.")) <>
-    command "theme" (info themeCommandParser (progDesc "Change the theme of the running qbar server."))
+    command "theme" (info themeCommandParser (progDesc "Change the theme of the running qbar server.")) <>
+    command "qubes" (info qubesCommandParser (progDesc "Display information about Qubes."))
   )
 
 serverCommandParser :: Parser (MainOptions -> IO ())
@@ -114,3 +116,9 @@ scriptBlockParser = helper <*> do
   clickEvents <- switch $ long "events" <> short 'e' <> help "Send click events to stdin of the script"
   script <- strArgument (metavar "SCRIPT" <> help "The script that will be executed with a shell.")
   return $ (if poll then addBlock . pollScriptBlock pollInterval else addBlock . scriptBlock clickEvents) script
+
+qubesCommandParser :: Parser (MainOptions -> IO ())
+qubesCommandParser = hsubparser (
+    command "stats" (info (pure $ const $ printEvents qubesVMStats) (progDesc "Subscribe to VM stats and print them to stdout.")) <>
+    command "events" (info (pure $ const $ printEvents qubesEvents) (progDesc "Subscribe to events and print them to stdout."))
+  )
-- 
GitLab