1. nakamura
  2. udon

Commits

nakamura  committed c8e95a2

add new subcommand: udon update

  • Participants
  • Parent commits 2962661
  • Branches default

Comments (0)

Files changed (1)

File src/Client.hs

View file
  • Ignore whitespace
 client ("ping":[])              = runCCommand commandPing
 client ("register":args)        = runCCommand (commandRegister args)
 client ("unregister":daemon:[]) = runCCommand (commandUnregister daemon)
+client ("update":daemon:cmd:args) = runCCommand (commandUpdate daemon cmd args)
 client ("edit":daemon:[])       = runCCommand (commandEdit daemon)
 client ("start":daemon:[])      = runCCommand (commandStart daemon)
 client ("stop":daemon:[])       = runCCommand (commandStop daemon "SIGTERM")
         , "    ping:                                     pong"
         , "    register [-n <name>] <cmd> [cmdargs...]:  register <cmd> as daemon"
         , "    unregister <daemon>:                      unregister daemon"
+        , "    update <daemon> <cmd> [cmdargs...]:       update <daemon> with <cmd>"
         , "    edit <daemon>:                            edit daemon"
         , "    start <daemon>:                           start <daemon>"
         , "    stop <daemon> [<signal>]:                 stop <daemon> with <signal>"
     hPrintM h $ UnregisterDaemon dn
     assertResponseOK =<< hGetResponse h
 
+commandUpdate :: String -> String -> [String] -> ClientCommand
+commandUpdate dn cmd args = do
+    cwd <- io getWorkingDirectory
+    env <- io getEnvironment
+    let d = Daemon
+                { dName      = dn
+                , dCommand   = cmd
+                , dArgs      = args
+                , dCwd       = cwd
+                , dEnv       = env
+                , dAutoStart = False
+                }
+    simpleCommand $ UpdateDaemon dn d
+
 commandEdit :: String -> ClientCommand
 commandEdit dn =
     withDaemonStatus dn $ \(dst, lst) -> do