Skip to content

Commit

Permalink
Reimplement shell interfacing with API from the "typed-process" package
Browse files Browse the repository at this point in the history
  • Loading branch information
DSONE\TZY1 committed Jan 30, 2018
1 parent 301e852 commit 087bb1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Data.Semigroup ((<>))
import Control.Monad
import System.Directory
import System.FilePath
import Data.Conduit.Shell hiding (info)
import System.Process.Typed
import System.Environment (getArgs, withArgs)
import Paths_tldr (version)
import Data.Version (showVersion)
Expand Down Expand Up @@ -39,22 +39,21 @@ tldrInitialized = do
initializeTldrPages :: IO ()
initializeTldrPages = do
initialized <- tldrInitialized
if initialized
then return ()
else do
homeDir <- getHomeDirectory
run $
do mkdir (homeDir </> tldrDirName)
cd (homeDir </> tldrDirName)
git "clone" repoHttpsUrl
initialized <- tldrInitialized
unless initialized $ do
homeDir <- getHomeDirectory
let cloneDir = homeDir </> tldrDirName
runProcess_ $ proc "mkdir" [cloneDir]
runProcess_ $ setWorkingDir cloneDir $ proc "git" ["clone", repoHttpsUrl]


updateTldrPages :: IO ()
updateTldrPages = do
homeDir <- getHomeDirectory
let repoDir = homeDir </> tldrDirName </> "tldr"
run $
do cd repoDir
git "pull" ["origin", "master"]
repoExists <- doesDirectoryExist repoDir
when repoExists $ do
runProcess_ $ setWorkingDir repoDir $ proc "git" ["pull", "origin", "master"]

updateOption :: Parser (a -> a)
updateOption = infoOption "update" (long "update" <> help "Update tldr pages")
Expand Down
2 changes: 1 addition & 1 deletion tldr.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ executable tldr
, optparse-applicative
, directory
, filepath
, shell-conduit >= 4.6.0
, typed-process >= 0.2
, semigroups
default-language: Haskell2010

Expand Down

0 comments on commit 087bb1d

Please sign in to comment.