Copyright | (c) Frederick Pringle 2023 |
---|---|
License | BSD-3-Clause |
Maintainer | freddyjepringle@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
This module defines data-types and runner functions for the hoyo command-line program.
Synopsis
- runCommand :: Command -> HoyoMonad ()
- modifyBookmarks :: ([Bookmark] -> [Bookmark]) -> HoyoMonad ()
- modifyBookmarksM :: ([Bookmark] -> HoyoMonad [Bookmark]) -> HoyoMonad ()
- runAdd :: AddOptions -> HoyoMonad ()
- runMove :: MoveOptions -> HoyoMonad ()
- runList :: ListOptions -> HoyoMonad ()
- runClear :: ClearOptions -> HoyoMonad ()
- runDelete :: DeleteOptions -> HoyoMonad ()
- runRefresh :: RefreshOptions -> HoyoMonad ()
- runConfig :: ConfigCommand -> HoyoMonad ()
- runCheck :: CheckOptions -> FilePath -> FilePath -> IO ()
- runDefaultCommand :: HoyoMonad ()
- data Options = Options {}
- data Command
- data AddOptions = AddOptions {
- addDirectory :: FilePath
- addName :: Maybe Text
- newtype MoveOptions = MoveOptions {}
- data ListOptions = ListOptions {}
- data ClearOptions = ClearOptions
- newtype DeleteOptions = DeleteOptions {}
- data RefreshOptions = RefreshOptions
- newtype ConfigPrintOptions = ConfigPrintOptions {}
- data ConfigResetOptions = ConfigResetOptions
- data ConfigSetOptions = ConfigSetOptions {}
- data ConfigAddDefaultOptions = ConfigAddDefaultOptions {}
- data ConfigCommand
- data CheckOptions = CheckOptions {}
- newtype HelpOptions = HelpOptions {}
- data GlobalOptions = GlobalOptions {}
- defaultGlobalOptions :: GlobalOptions
- data OverrideOptions = OverrideOptions {}
- defaultOverrideOptions :: OverrideOptions
- overrideConfig :: OverrideOptions -> Config -> Config
- overrideEnv :: OverrideOptions -> Env -> Env
- verifyOverrides :: OverrideOptions -> Maybe Text
- combOverride :: Bool -> Bool -> MaybeOverride
- data MaybeOverride
Running CLI commands
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.
Specific command runners
runAdd :: AddOptions -> HoyoMonad () Source #
Run the "add" command: add a new bookmark.
runMove :: MoveOptions -> HoyoMonad () Source #
Run the "move" command: search for a bookmark and cd
to it.
runList :: ListOptions -> HoyoMonad () Source #
Run the "list" command: list all the saved bookmarks.
runClear :: ClearOptions -> HoyoMonad () Source #
Run the "clear" command: delete all the saved bookmarks.
runDelete :: DeleteOptions -> HoyoMonad () Source #
Run the "delete" command: search for a bookmark and delete it.
runRefresh :: RefreshOptions -> HoyoMonad () Source #
Run the "refresh" command: re-index bookmarks.
runConfig :: ConfigCommand -> HoyoMonad () Source #
Run the "config" command: dispatch on the given sub-command.
runCheck :: CheckOptions -> FilePath -> FilePath -> IO () Source #
Run the "config check" command: validate the current config and bookmarks files.
runDefaultCommand :: HoyoMonad () Source #
Run the default command, if it has been specified by the user.
Types
The final result of parsing the CLI arguments. Contains a command and all information for that command, and any global options that have been set.
The core data-type for the hoyo CLI. The Command
is parsed from the command-line,
then runCommand
dispatches on the type.
data AddOptions Source #
Options for the "add" command to be parsed from the command-line.
Instances
Eq AddOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: AddOptions -> AddOptions -> Bool # (/=) :: AddOptions -> AddOptions -> Bool # | |
Show AddOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> AddOptions -> ShowS # show :: AddOptions -> String # showList :: [AddOptions] -> ShowS # |
newtype MoveOptions Source #
Options for the "move" command to be parsed from the command-line.
Instances
Eq MoveOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: MoveOptions -> MoveOptions -> Bool # (/=) :: MoveOptions -> MoveOptions -> Bool # | |
Show MoveOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> MoveOptions -> ShowS # show :: MoveOptions -> String # showList :: [MoveOptions] -> ShowS # |
data ListOptions Source #
Options for the "list" command to be parsed from the command-line.
Instances
Eq ListOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: ListOptions -> ListOptions -> Bool # (/=) :: ListOptions -> ListOptions -> Bool # | |
Show ListOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> ListOptions -> ShowS # show :: ListOptions -> String # showList :: [ListOptions] -> ShowS # |
data ClearOptions Source #
Options for the "clear" command to be parsed from the command-line.
Instances
Eq ClearOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: ClearOptions -> ClearOptions -> Bool # (/=) :: ClearOptions -> ClearOptions -> Bool # | |
Show ClearOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> ClearOptions -> ShowS # show :: ClearOptions -> String # showList :: [ClearOptions] -> ShowS # |
newtype DeleteOptions Source #
Options for the "delete" command to be parsed from the command-line.
Instances
Eq DeleteOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: DeleteOptions -> DeleteOptions -> Bool # (/=) :: DeleteOptions -> DeleteOptions -> Bool # | |
Show DeleteOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> DeleteOptions -> ShowS # show :: DeleteOptions -> String # showList :: [DeleteOptions] -> ShowS # |
data RefreshOptions Source #
Options for the "refresh" command to be parsed from the command-line.
Instances
Eq RefreshOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: RefreshOptions -> RefreshOptions -> Bool # (/=) :: RefreshOptions -> RefreshOptions -> Bool # | |
Show RefreshOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> RefreshOptions -> ShowS # show :: RefreshOptions -> String # showList :: [RefreshOptions] -> ShowS # |
newtype ConfigPrintOptions Source #
Options for the "config print" command to be parsed from the command-line.
Instances
Eq ConfigPrintOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: ConfigPrintOptions -> ConfigPrintOptions -> Bool # (/=) :: ConfigPrintOptions -> ConfigPrintOptions -> Bool # | |
Show ConfigPrintOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> ConfigPrintOptions -> ShowS # show :: ConfigPrintOptions -> String # showList :: [ConfigPrintOptions] -> ShowS # |
data ConfigResetOptions Source #
Options for the "config reset" command to be parsed from the command-line.
Instances
Eq ConfigResetOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: ConfigResetOptions -> ConfigResetOptions -> Bool # (/=) :: ConfigResetOptions -> ConfigResetOptions -> Bool # | |
Show ConfigResetOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> ConfigResetOptions -> ShowS # show :: ConfigResetOptions -> String # showList :: [ConfigResetOptions] -> ShowS # |
data ConfigSetOptions Source #
Options for the "config set" command to be parsed from the command-line.
Instances
Eq ConfigSetOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: ConfigSetOptions -> ConfigSetOptions -> Bool # (/=) :: ConfigSetOptions -> ConfigSetOptions -> Bool # | |
Show ConfigSetOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> ConfigSetOptions -> ShowS # show :: ConfigSetOptions -> String # showList :: [ConfigSetOptions] -> ShowS # |
data ConfigAddDefaultOptions Source #
Options for the "config add-default" command to be parsed from the command-line.
Instances
Eq ConfigAddDefaultOptions Source # | |
Defined in Hoyo.Internal.Types | |
Show ConfigAddDefaultOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> ConfigAddDefaultOptions -> ShowS # show :: ConfigAddDefaultOptions -> String # showList :: [ConfigAddDefaultOptions] -> ShowS # |
data ConfigCommand Source #
Options for the "config" command to be parsed from the command-line.
Print ConfigPrintOptions | |
Reset ConfigResetOptions | |
Set ConfigSetOptions | |
AddDefaultBookmark ConfigAddDefaultOptions |
Instances
Eq ConfigCommand Source # | |
Defined in Hoyo.Internal.Types (==) :: ConfigCommand -> ConfigCommand -> Bool # (/=) :: ConfigCommand -> ConfigCommand -> Bool # | |
Show ConfigCommand Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> ConfigCommand -> ShowS # show :: ConfigCommand -> String # showList :: [ConfigCommand] -> ShowS # |
data CheckOptions Source #
Options for the "check" command to be parsed from the command-line.
Instances
Eq CheckOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: CheckOptions -> CheckOptions -> Bool # (/=) :: CheckOptions -> CheckOptions -> Bool # | |
Show CheckOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> CheckOptions -> ShowS # show :: CheckOptions -> String # showList :: [CheckOptions] -> ShowS # |
newtype HelpOptions Source #
Options for the "help" command to be parsed from the command-line.
Instances
Eq HelpOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: HelpOptions -> HelpOptions -> Bool # (/=) :: HelpOptions -> HelpOptions -> Bool # | |
Show HelpOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> HelpOptions -> ShowS # show :: HelpOptions -> String # showList :: [HelpOptions] -> ShowS # |
data GlobalOptions Source #
CLI options that can be set regardless of which command is run.
Instances
Eq GlobalOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: GlobalOptions -> GlobalOptions -> Bool # (/=) :: GlobalOptions -> GlobalOptions -> Bool # | |
Show GlobalOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> GlobalOptions -> ShowS # show :: GlobalOptions -> String # showList :: [GlobalOptions] -> ShowS # |
defaultGlobalOptions :: GlobalOptions Source #
Default global options. In general this should do nothing.
data OverrideOptions Source #
Config settings that can be overriden using command-line flags.
Instances
Eq OverrideOptions Source # | |
Defined in Hoyo.Internal.Types (==) :: OverrideOptions -> OverrideOptions -> Bool # (/=) :: OverrideOptions -> OverrideOptions -> Bool # | |
Show OverrideOptions Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> OverrideOptions -> ShowS # show :: OverrideOptions -> String # showList :: [OverrideOptions] -> ShowS # |
defaultOverrideOptions :: OverrideOptions Source #
The default behaviour is to override nothing.
overrideConfig :: OverrideOptions -> Config -> Config Source #
Apply the override options to a Config
.
overrideEnv :: OverrideOptions -> Env -> Env Source #
Apply the override options to an Env
.
verifyOverrides :: OverrideOptions -> Maybe Text Source #
Check that there are no conflicting overrides.
combOverride :: Bool -> Bool -> MaybeOverride Source #
Combine a config flag with a command-line flag, checking for conflicts.
data MaybeOverride Source #
Datatype for representing a command-line settings override.
Instances
Eq MaybeOverride Source # | |
Defined in Hoyo.Internal.Types (==) :: MaybeOverride -> MaybeOverride -> Bool # (/=) :: MaybeOverride -> MaybeOverride -> Bool # | |
Show MaybeOverride Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> MaybeOverride -> ShowS # show :: MaybeOverride -> String # showList :: [MaybeOverride] -> ShowS # |