mirror of
https://github.com/kowainik/hit-on.git
synced 2024-09-19 07:57:11 +03:00
Implement orphan instance for shell (#14)
This commit is contained in:
parent
77ba7dd540
commit
e50d05300c
@ -25,6 +25,7 @@ library
|
||||
exposed-modules: Hit
|
||||
Hit.Cli
|
||||
Hit.ColorTerminal
|
||||
Hit.Shell
|
||||
|
||||
autogen-modules: Paths_hit_on
|
||||
other-modules: Paths_hit_on
|
||||
@ -35,6 +36,7 @@ library
|
||||
, gitrev ^>= 1.3
|
||||
, optparse-applicative ^>= 0.14
|
||||
, relude ^>= 0.4
|
||||
, process ^>= 1.6.3
|
||||
|
||||
ghc-options: -Wall
|
||||
-Wincomplete-uni-patterns
|
||||
|
23
src/Hit/Shell.hs
Normal file
23
src/Hit/Shell.hs
Normal file
@ -0,0 +1,23 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
||||
{- | This module contains neat orphan instance for function to be able to call
|
||||
commands using just strings.
|
||||
-}
|
||||
|
||||
module Hit.Shell
|
||||
(
|
||||
) where
|
||||
|
||||
import System.Process (callCommand, showCommandForUser)
|
||||
|
||||
|
||||
-- | This is needed to be able to call commands by writing strings.
|
||||
instance (a ~ Text, b ~ ()) => IsString ([a] -> IO b) where
|
||||
fromString :: String -> [Text] -> IO ()
|
||||
fromString cmd args = do
|
||||
let cmdStr = showCommandForUser cmd (map toString args)
|
||||
putStrLn $ "⚙ " ++ cmdStr
|
||||
callCommand cmdStr
|
Loading…
Reference in New Issue
Block a user