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

Hoyo.Command

Description

This module defines data-types and runner functions for the hoyo command-line program.

Synopsis

Running CLI commands

runCommand :: Command -> HoyoMonad () Source #

Run a Command in the hoyo environment.

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

data Options Source #

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.

Constructors

Options 

Instances

Instances details
Eq Options Source # 
Instance details

Defined in Hoyo.Internal.Types

Methods

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

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

Show Options Source # 
Instance details

Defined in Hoyo.Internal.Types

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

data AddOptions Source #

Options for the "add" command to be parsed from the command-line.

Constructors

AddOptions 

Instances

Instances details
Eq AddOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show AddOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

newtype MoveOptions Source #

Options for the "move" command to be parsed from the command-line.

Constructors

MoveOptions 

Instances

Instances details
Eq MoveOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show MoveOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

data ListOptions Source #

Options for the "list" command to be parsed from the command-line.

Instances

Instances details
Eq ListOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show ListOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

data ClearOptions Source #

Options for the "clear" command to be parsed from the command-line.

Constructors

ClearOptions 

Instances

Instances details
Eq ClearOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show ClearOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

newtype DeleteOptions Source #

Options for the "delete" command to be parsed from the command-line.

Instances

Instances details
Eq DeleteOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show DeleteOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

data RefreshOptions Source #

Options for the "refresh" command to be parsed from the command-line.

Constructors

RefreshOptions 

Instances

Instances details
Eq RefreshOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show RefreshOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

newtype ConfigPrintOptions Source #

Options for the "config print" command to be parsed from the command-line.

data ConfigResetOptions Source #

Options for the "config reset" command to be parsed from the command-line.

Constructors

ConfigResetOptions 

data ConfigSetOptions Source #

Options for the "config set" command to be parsed from the command-line.

Constructors

ConfigSetOptions 

Fields

data ConfigAddDefaultOptions Source #

Options for the "config add-default" command to be parsed from the command-line.

data ConfigCommand Source #

Options for the "config" command to be parsed from the command-line.

Instances

Instances details
Eq ConfigCommand Source # 
Instance details

Defined in Hoyo.Internal.Types

Show ConfigCommand Source # 
Instance details

Defined in Hoyo.Internal.Types

data CheckOptions Source #

Options for the "check" command to be parsed from the command-line.

Constructors

CheckOptions 

Instances

Instances details
Eq CheckOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show CheckOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

newtype HelpOptions Source #

Options for the "help" command to be parsed from the command-line.

Constructors

HelpOptions 

Instances

Instances details
Eq HelpOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show HelpOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

data GlobalOptions Source #

CLI options that can be set regardless of which command is run.

Instances

Instances details
Eq GlobalOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

Show GlobalOptions Source # 
Instance details

Defined in Hoyo.Internal.Types

defaultGlobalOptions :: GlobalOptions Source #

Default global options. In general this should do nothing.

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

Instances details
Eq MaybeOverride Source # 
Instance details

Defined in Hoyo.Internal.Types

Show MaybeOverride Source # 
Instance details

Defined in Hoyo.Internal.Types