-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A DSL to describe common shell operations and interpeters for running them locally and remotely. -- @package handsy @version 0.0.13 module System.Handsy.Internal type Handsy a = ProgramT HandsyInstruction IO a interpret :: IO r -> (r -> IO ()) -> (r -> String -> ByteString -> IO (ExitCode, ByteString, ByteString)) -> Options -> Handsy a -> IO a interpretSimple :: (FilePath -> ByteString -> IO (ExitCode, ByteString, ByteString)) -> Options -> Handsy a -> IO a shell :: FilePath -> ByteString -> Handsy (ExitCode, ByteString, ByteString) data Options Options :: Bool -> Options -- | Log commands to stderr before running debug :: Options -> Bool instance Default Options module System.Handsy type Handsy a = ProgramT HandsyInstruction IO a -- | Executes the actions locally run :: Options -> Handsy a -> IO a -- | Executes the given string in shell. Example: -- --
-- shell "ls" $~ def{cwd="/var/www"}
--
shell :: String -> CommandOptions -> Handsy (ExitCode, ByteString, ByteString)
-- | Runs a command
command :: FilePath -> [String] -> CommandOptions -> Handsy (ExitCode, ByteString, ByteString)
-- | Reads a file and returns the contents of the file.
readFile :: FilePath -> Handsy ByteString
-- | writeFile file str function writes the bytestring
-- str, to the file file.
writeFile :: FilePath -> ByteString -> Handsy ()
-- | appendFile file str function appends the bytestring
-- str, to the file file.
appendFile :: FilePath -> ByteString -> Handsy ()
-- | Same as shell, but ExitFailure is a runtime error.
shell_ :: String -> CommandOptions -> Handsy (ByteString, ByteString)
-- | Same as command, but ExitFailure is a runtime error.
command_ :: FilePath -> [String] -> CommandOptions -> Handsy (ByteString, ByteString)
data CommandOptions
CommandOptions :: ByteString -> String -> CommandOptions
stdin :: CommandOptions -> ByteString
cwd :: CommandOptions -> String
data Options
Options :: Bool -> Options
-- | Log commands to stderr before running
debug :: Options -> Bool
-- | Defines the exit codes that a program can return.
data ExitCode :: *
-- | indicates successful termination;
ExitSuccess :: ExitCode
-- | indicates program failure with an exit code. The exact interpretation
-- of the code is operating-system dependent. In particular, some values
-- may be prohibited (e.g. 0 on a POSIX-compliant system).
ExitFailure :: Int -> ExitCode
-- | The default value for this type.
def :: Default a => a
instance Show CommandOptions
instance Default CommandOptions
module System.Handsy.Util
class IsReturnValue a
stdout :: IsReturnValue a => a -> ByteString
stderr :: IsReturnValue a => a -> ByteString
exitCode :: IsReturnValue a => a -> ExitCode
isSuccessful :: IsReturnValue a => a -> Bool
isExitSuccess :: ExitCode -> Bool
-- | Extract lines from a ByteString. Useful for parsing unix commands.
strLines :: ByteString -> [String]
-- | Waits specified number of seconds
sleep :: Int -> Handsy ()
-- | Creates a temporary file
mkTemp :: String -> Handsy String
-- | Creates a temporary directory
mkTempDir :: String -> Handsy String
-- | Returns if the specified process is running. Uses pidof
isRunning :: String -> Handsy Bool
data OS
NixOS :: OS
Debian :: OS
Ubuntu :: OS
RHEL :: OS
CentOS :: OS
Fedora :: OS
ArchLinux :: OS
-- | Guesses the os using `/etc/os-release`. This currently only supports
-- Linux distributions abiding systemd standards.
os :: Handsy (Maybe OS)
instance Show OS
instance Eq OS
instance IsReturnValue (ExitCode, ByteString, ByteString)
instance IsReturnValue (ByteString, ByteString)
module System.Handsy.Remote
-- | Executes the actions at a remote host
runRemote :: Options -> Host -> SSHOptions -> Handsy a -> IO a
type Host = String
data SSHOptions
SSHOptions :: FilePath -> Int -> Bool -> SSHOptions
-- | Path of ssh command
sshPath :: SSHOptions -> FilePath
-- | Port to connect
sshPort :: SSHOptions -> Int
-- | Whether to use control master for SSH connections. This significantly
-- reduces execution time.
controlMaster :: SSHOptions -> Bool
-- | Copies a local file to remote host
pushFile :: FilePath -> FilePath -> Handsy ()
-- | Fetches a file from remote host
pullFile :: FilePath -> FilePath -> Handsy ()
-- | The default value for this type.
def :: Default a => a
instance Default SSHOptions
module System.Handsy.Tutorial