hoyo-0.6.0.0: Bookmark directories for cd
Copyright(c) Frederick Pringle 2023
LicenseBSD-3-Clause
Maintainerfreddyjepringle@gmail.com
Safe HaskellNone
LanguageHaskell2010

Hoyo

Description

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

Bookmarks

data Bookmark Source #

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.

Instances

Instances details
Eq Bookmark Source # 
Instance details

Defined in Hoyo.Internal.Types

Show Bookmark Source # 
Instance details

Defined in Hoyo.Internal.Types

newtype Bookmarks Source #

Wrapper for [Bookmark].

Constructors

Bookmarks 

Fields

Instances

Instances details
Show Bookmarks Source # 
Instance details

Defined in Hoyo.Internal.Types

searchBookmarks :: BookmarkSearchTerm -> Bookmarks -> ([Bookmark], [Bookmark]) Source #

searchBookmarks searchTerm bookmarks partitions bookmarks into a list of Bookmarks 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.

Config

data Config Source #

A representation of hoyo settings.

Instances

Instances details
Eq Config Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

Show Config Source # 
Instance details

Defined in Hoyo.Internal.Types

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.Env

CLI commands

data Command Source #

The core data-type for the hoyo CLI. The Command is parsed from the command-line, then runCommand dispatches on the type.

Instances

Instances details
Eq Command Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

(==) :: Command -> Command -> Bool #

(/=) :: Command -> Command -> Bool #

Show Command Source # 
Instance details

Defined in Hoyo.Internal.Types

runCommand :: Command -> HoyoMonad () Source #

Run a Command in the hoyo environment.

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.

Instances

Instances details
Eq HoyoException Source # 
Instance details

Defined in Hoyo.Internal.Types

Show HoyoException Source # 
Instance details

Defined in Hoyo.Internal.Types

Generic HoyoException Source # 
Instance details

Defined in Hoyo.Internal.Types

Associated Types

type Rep HoyoException :: Type -> Type #

Semigroup HoyoException Source # 
Instance details

Defined in Hoyo.Internal.Types

MonadError HoyoException HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

type Rep HoyoException Source # 
Instance details

Defined in Hoyo.Internal.Types

data HoyoMonad a Source #

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

Instances details
Monad HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

(>>=) :: HoyoMonad a -> (a -> HoyoMonad b) -> HoyoMonad b #

(>>) :: HoyoMonad a -> HoyoMonad b -> HoyoMonad b #

return :: a -> HoyoMonad a #

Functor HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

fmap :: (a -> b) -> HoyoMonad a -> HoyoMonad b #

(<$) :: a -> HoyoMonad b -> HoyoMonad a #

Applicative HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

pure :: a -> HoyoMonad a #

(<*>) :: HoyoMonad (a -> b) -> HoyoMonad a -> HoyoMonad b #

liftA2 :: (a -> b -> c) -> HoyoMonad a -> HoyoMonad b -> HoyoMonad c #

(*>) :: HoyoMonad a -> HoyoMonad b -> HoyoMonad b #

(<*) :: HoyoMonad a -> HoyoMonad b -> HoyoMonad a #

MonadIO HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

liftIO :: IO a -> HoyoMonad a #

MonadThrow HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

throwM :: Exception e => e -> HoyoMonad a #

MonadCatch HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

catch :: Exception e => HoyoMonad a -> (e -> HoyoMonad a) -> HoyoMonad a #

MonadReader Env HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

ask :: HoyoMonad Env #

local :: (Env -> Env) -> HoyoMonad a -> HoyoMonad a #

reader :: (Env -> a) -> HoyoMonad a #

MonadError HoyoException HoyoMonad Source # 
Instance details

Defined in Hoyo.Internal.Types

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.

assert :: HoyoException -> HoyoMonad Bool -> HoyoMonad () Source #

Throw an error if a check fails.

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.