Created
January 6, 2017 11:16
-
-
Save 0rca/f35ee97e5804b87c14114df852a8c00f to your computer and use it in GitHub Desktop.
cli tool in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack --silent runhaskell | |
{-# LANGUAGE OverloadedStrings #-} | |
import Console.Options | |
import Turtle | |
import Data.Text hiding (empty) | |
main = defaultMain $ do | |
programName "cli" | |
programDescription "personal CLI utilities" | |
command "help" $ do | |
action $ \_ -> do | |
echo "Usage: cli [command] [arguments]" | |
echo "" | |
echo "Available commands:" | |
echo " posgres start/stop posgresql server" | |
echo " version prints version" | |
echo "" | |
command "version" $ do | |
action $ \_ -> do | |
echo "cli version 0.0.1" | |
command "postgres" $ do | |
command "start" $ | |
action $ \toParam -> do | |
code <- shell "tmux new-session -d -s \"postgresql\" -n posgres-server postgres -D /usr/local/var/postgres" empty | |
guard (code == ExitSuccess) | |
echo "started" | |
command "stop" $ | |
action $ \toParam -> do | |
shell "tmux send-keys -t \"postgresql\" C-c C-d" empty | |
echo "stopped" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment