aura-2.2.1: A secure package manager for Arch Linux and the AUR.

Copyright(c) Colin Woodbury 2012 - 2020
LicenseGPL3
MaintainerColin Woodbury <colin@fosskers.ca>
Safe HaskellNone
LanguageHaskell2010

Aura.Utils

Contents

Description

Utility functions specific to Aura.

Synopsis

Strings

data Pattern Source #

For regex-like find-and-replace in some Text.

Constructors

Pattern 

Fields

replaceByPatt :: [Pattern] -> Text -> Text Source #

Replaces a (p)attern with a (t)arget in a line if possible.

searchLines :: Text -> [Text] -> [Text] Source #

Find lines which contain some given Text.

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?

chown :: MonadIO m => User -> Path Absolute -> [String] -> m () Source #

Mark some Path as being owned by a 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.

Misc.

maybe' :: b -> Maybe a -> (a -> b) -> b Source #

maybe with the function at the end.

fmapEither :: (a -> Either b c) -> [a] -> ([b], [c]) Source #

Borrowed from Compactable.

traverseEither :: Applicative f => (a -> f (Either b c)) -> [a] -> f ([b], [c]) Source #

Borrowed from Compactable.

groupsOf :: Int -> [a] -> [[a]] Source #

Break a list into groups of n elements. The last item in the result is not guaranteed to have the same length as the others.