Copyright | (c) Colin Woodbury 2012 - 2020 |
---|---|
License | GPL3 |
Maintainer | Colin Woodbury <colin@fosskers.ca> |
Safe Haskell | None |
Language | Haskell2010 |
Utility functions specific to Aura.
Synopsis
- data Pattern = Pattern {}
- replaceByPatt :: [Pattern] -> Text -> Text
- searchLines :: Text -> [Text] -> [Text]
- urlContents :: Manager -> String -> IO (Maybe ByteString)
- csi :: [Int] -> ByteString -> ByteString
- cursorUpLineCode :: Int -> ByteString
- hideCursor :: IO ()
- showCursor :: IO ()
- raiseCursorBy :: Int -> IO ()
- getTrueUser :: Environment -> Maybe User
- getEditor :: Environment -> FilePath
- getLocale :: Environment -> Text
- hasRootPriv :: Environment -> Bool
- isTrueRoot :: Environment -> Bool
- chown :: MonadIO m => User -> Path Absolute -> [String] -> m ()
- ifFile :: MonadIO m => (a -> m a) -> m b -> Path Absolute -> a -> m a
- putStrLnA :: Settings -> Doc AnsiStyle -> IO ()
- putText :: Text -> IO ()
- putTextLn :: Text -> IO ()
- colourCheck :: Settings -> Doc ann -> Doc ann
- entrify :: Settings -> [Text] -> [Doc AnsiStyle] -> Doc AnsiStyle
- optionalPrompt :: Settings -> (Language -> Doc AnsiStyle) -> IO Bool
- getSelection :: Foldable f => (a -> Text) -> f a -> IO a
- maybe' :: b -> Maybe a -> (a -> b) -> b
Strings
For regex-like find-and-replace in some Text
.
replaceByPatt :: [Pattern] -> Text -> Text Source #
Replaces a (p)attern with a (t)arget in a line if possible.
Network
urlContents :: Manager -> String -> IO (Maybe ByteString) Source #
Assumes the given URL is correctly formatted.
Shell
csi :: [Int] -> ByteString -> ByteString Source #
Code borrowed from `ansi-terminal` library by Max Bolingbroke.
cursorUpLineCode :: Int -> ByteString Source #
Terminal code for raising the cursor.
hideCursor :: IO () Source #
Hide the cursor in a terminal.
showCursor :: IO () Source #
Restore a cursor to visiblity in the terminal.
raiseCursorBy :: Int -> IO () Source #
Raise the cursor by n
lines.
getTrueUser :: Environment -> Maybe User Source #
This will get the true user name regardless of sudo-ing.
getEditor :: Environment -> FilePath Source #
vi
is a sensible default, it should be installed by
on any Arch system.
getLocale :: Environment -> Text Source #
This will get the locale variable for translations from the environment
hasRootPriv :: Environment -> Bool Source #
Is the user root, or using sudo?
isTrueRoot :: Environment -> Bool Source #
Is the current user of Aura the true root
user, and not just a sudo user?
File IO
ifFile :: MonadIO m => (a -> m a) -> m b -> Path Absolute -> a -> m a Source #
If a file exists, it performs action t
on the argument.
| If the file doesn't exist, it performs f
and returns the argument.
Output
putStrLnA :: Settings -> Doc AnsiStyle -> IO () Source #
Print a Doc
with Aura flair after performing a colourCheck
.
colourCheck :: Settings -> Doc ann -> Doc ann Source #
Strip colours from a Doc
if --color=never
is specified,
or if the output target isn't a terminal.
entrify :: Settings -> [Text] -> [Doc AnsiStyle] -> Doc AnsiStyle Source #
Format two lists into two nice rows a la `-Qi` or `-Si`.
User Input
optionalPrompt :: Settings -> (Language -> Doc AnsiStyle) -> IO Bool Source #
Doesn't prompt when `--noconfirm` is used.
getSelection :: Foldable f => (a -> Text) -> f a -> IO a Source #
Given a number of selections, allows the user to choose one.