Copyright | (c) Frederick Pringle 2023 |
---|---|
License | BSD-3-Clause |
Maintainer | freddyjepringle@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
hoyo is a command-line utility that lets the user save directories
as bookmarks (similar to in the browser) and easily cd
to them.
Synopsis
- data Bookmark = Bookmark {}
- newtype Bookmarks = Bookmarks {
- unBookmarks :: [Bookmark]
- searchBookmarks :: BookmarkSearchTerm -> Bookmarks -> ([Bookmark], [Bookmark])
- filterBookmarks :: Maybe Text -> Maybe Text -> Bookmark -> Bool
- module Hoyo.Bookmark
- data Config = Config {
- _failOnError :: !(ConfigValue 'TBool)
- _displayCreationTime :: !(ConfigValue 'TBool)
- _enableClearing :: !(ConfigValue 'TBool)
- _enableReset :: !(ConfigValue 'TBool)
- _backupBeforeClear :: !(ConfigValue 'TBool)
- _defaultBookmarks :: !(ConfigValue ('TList 'TDefaultBookmark))
- _defaultCommand :: !(ConfigValue ('TMaybe 'TCommand))
- defaultConfig :: Config
- setConfig :: MonadError HoyoException m => Text -> Text -> Config -> m Config
- module Hoyo.Config
- module Hoyo.Env
- data Command
- runCommand :: Command -> HoyoMonad ()
- module Hoyo.Command
- runHoyo :: HoyoMonad a -> Env -> IO (Either HoyoException a)
- withFiles :: GlobalOptions -> FilePath -> FilePath -> HoyoMonad a -> IO (Either HoyoException a)
- getEnvAndRunHoyo :: GlobalOptions -> HoyoMonad a -> FilePath -> FilePath -> IO a
- getEnvAndRunCommand :: Options -> FilePath -> FilePath -> IO ()
- data HoyoException
- data HoyoMonad a
- modifyBookmarks :: ([Bookmark] -> [Bookmark]) -> HoyoMonad ()
- modifyBookmarksM :: ([Bookmark] -> HoyoMonad [Bookmark]) -> HoyoMonad ()
- printStderr :: MonadIO m => Text -> m ()
- printStdout :: MonadIO m => Text -> m ()
- readInt :: MonadError HoyoException m => Text -> m Int
- readBool :: MonadError HoyoException m => Text -> m Bool
- backupFile :: (MonadIO m, MonadError HoyoException m) => FilePath -> String -> m ()
- assert :: HoyoException -> HoyoMonad Bool -> HoyoMonad ()
- assertVerbose :: HoyoException -> HoyoMonad Bool -> HoyoMonad Bool
- versionString :: String
Bookmarks
Bookmark a directory for easy cd
. A bookmark remembers the directory,
the index, the creation time, and optionally a user-specified nickname
for the bookmark.
Bookmark | |
|
Wrapper for [
.Bookmark
]
Bookmarks | |
|
searchBookmarks :: BookmarkSearchTerm -> Bookmarks -> ([Bookmark], [Bookmark]) Source #
searchBookmarks searchTerm bookmarks
partitions bookmarks
into a list of
Bookmark
s that match the search term and a list of those that do not.
filterBookmarks :: Maybe Text -> Maybe Text -> Bookmark -> Bool Source #
Given a bookmark name and a bookmark directory, test if a bookmark matches those filters.
module Hoyo.Bookmark
Config
A representation of hoyo settings.
Config | |
|
defaultConfig :: Config Source #
The default config for hoyo.
setConfig :: MonadError HoyoException m => Text -> Text -> Config -> m Config Source #
Try to set a key-value pair in the config.
module Hoyo.Config
module Hoyo.Env
CLI commands
The core data-type for the hoyo CLI. The Command
is parsed from the command-line,
then runCommand
dispatches on the type.
module Hoyo.Command
Utility functions
runHoyo :: HoyoMonad a -> Env -> IO (Either HoyoException a) Source #
Given a hoyo Env
, run a monadic action in IO.
withFiles :: GlobalOptions -> FilePath -> FilePath -> HoyoMonad a -> IO (Either HoyoException a) Source #
withFiles globals bFp sFp hoyo
gets the environment saved in
the bookmark path (bFp
) and the config path (sFp
), applies the global
options and overrides in globals
, and runs hoyo
, returning either
the result or an error message.
getEnvAndRunHoyo :: GlobalOptions -> HoyoMonad a -> FilePath -> FilePath -> IO a Source #
getEnvAndRunHoyo globals hoyo bFp sFp
gets the environment saved in
the bookmark path (bFp
) and the config path (sFp
), applies the global
options and overrides in globals
, and runs hoyo
, either printing an error
message or discarding the result.
getEnvAndRunCommand :: Options -> FilePath -> FilePath -> IO () Source #
getEnvAndRunHoyo opts bFp sFp
gets the environment saved in
the bookmark path (bFp
) and the config path (sFp
), and runs the command
specified by opts
.
data HoyoException Source #
A custom hierarchical exception type for hoyo.
ConfigException [Text] | |
CommandException CommandException | |
IOException IOError | |
FileSystemException FileSystemException | |
ParseException [Text] | |
MultipleExceptions (NonEmpty HoyoException) |
Instances
HoyoMonad
is the main monad stack for the hoyo program. It's essentially a wrapper
around ExceptT T.Text (ReaderT Env IO)
: in other words,
HoyoMonad a
is equivalent to Env -> IO (Either T.Text a)
Instances
Monad HoyoMonad Source # | |
Functor HoyoMonad Source # | |
Applicative HoyoMonad Source # | |
MonadIO HoyoMonad Source # | |
Defined in Hoyo.Internal.Types | |
MonadThrow HoyoMonad Source # | |
Defined in Hoyo.Internal.Types | |
MonadCatch HoyoMonad Source # | |
MonadReader Env HoyoMonad Source # | |
MonadError HoyoException HoyoMonad Source # | |
Defined in Hoyo.Internal.Types throwError :: HoyoException -> HoyoMonad a # catchError :: HoyoMonad a -> (HoyoException -> HoyoMonad a) -> HoyoMonad a # |
modifyBookmarks :: ([Bookmark] -> [Bookmark]) -> HoyoMonad () Source #
Helper function whenever we need to modify the saved bookmarks.
modifyBookmarks f
retrieves the current bookmarks, applies f
,
and saves them back to file.
modifyBookmarksM :: ([Bookmark] -> HoyoMonad [Bookmark]) -> HoyoMonad () Source #
Helper function twhenever we need to modify the saved bookmarks, and need access to the hoyo environment.
modifyBookmarks f
retrieves the current bookmarks, applies f
in the hoyo environment, and saves them back to file.
printStderr :: MonadIO m => Text -> m () Source #
Print to stderr.
printStdout :: MonadIO m => Text -> m () Source #
Print to stdout.
readInt :: MonadError HoyoException m => Text -> m Int Source #
Try to read an Int
.
readBool :: MonadError HoyoException m => Text -> m Bool Source #
Try to read a Bool
.
backupFile :: (MonadIO m, MonadError HoyoException m) => FilePath -> String -> m () Source #
Try to back-up a file. Used when the "backup_before_clear" option is set.
assertVerbose :: HoyoException -> HoyoMonad Bool -> HoyoMonad Bool Source #
Throw an error if a check fails AND the "fail_on_error" flag is set.
Misc
versionString :: String Source #
The current hoyo
version.