Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Unison.CommandLine.InputPattern
Contents
Synopsis
- data InputPattern = InputPattern {
- patternName :: String
- aliases :: [String]
- visibility :: Visibility
- params :: Parameters
- help :: Pretty ColorText
- parse :: Arguments -> Either (Pretty ColorText) Input
- type ParameterDescription = Text
- data ParameterType = ParameterType {
- typeName :: String
- suggestions :: forall m v a. MonadIO m => String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion]
- fzfResolver :: Maybe FZFResolver
- isStructured :: Bool
- type Parameter = (ParameterDescription, ParameterType)
- data TrailingParameters
- data Parameters = Parameters {}
- type Argument = Either String StructuredArgument
- type Arguments = [Argument]
- noParams :: Parameters
- foldParamsWithM :: Monad m => (state -> Parameter -> arg -> m (state, [arg])) -> state -> Parameters -> [arg] -> m (Either (NonEmpty arg) (state, Parameters))
- paramType :: Parameters -> Int -> Maybe ParameterType
- data FZFResolver = FZFResolver {
- getOptions :: OptionFetcher
- data Visibility
- minArgs :: Parameters -> Int
- maxArgs :: Parameters -> Maybe Int
- unionSuggestions :: forall m v a. MonadIO m => [String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion]] -> String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion]
- suggestionFallbacks :: forall m v a. MonadIO m => [String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion]] -> String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion]
Documentation
data InputPattern Source #
Constructors
InputPattern | |
Fields
|
type ParameterDescription = Text Source #
This should fit grammatically into sentences like “I was expecting an argument for the paramDesc”. E.g. “namespace to merge”, “definition to delete”, “remote target to push to” etc.
data ParameterType Source #
Constructors
ParameterType | |
Fields
|
type Parameter = (ParameterDescription, ParameterType) Source #
data TrailingParameters Source #
data Parameters Source #
The Parameters
for an InputPattern
are roughly
[required …] ([optional …] [catchAll] | NonEmpty catchAll)
Constructors
Parameters | |
Fields |
type Argument = Either String StructuredArgument Source #
An argument to a command is either a string provided by the user which needs to be parsed or a numbered argument that doesn’t need to be parsed, as we’ve preserved its representation (although the numbered argument could still be of the wrong type, which should result in an error).
noParams :: Parameters Source #
This is the parameter structure for a pattern that doesn’t accept any arguments.
Arguments
:: Monad m | |
=> (state -> Parameter -> arg -> m (state, [arg])) | Each step needs to return a new incremental result, but can also return additional arguments to apply in later steps. This allows for the expansion of an argument to multiple arguments, as with numbered arg ranges. |
-> state | The initial state. |
-> Parameters | |
-> [arg] | |
-> m (Either (NonEmpty arg) (state, Parameters)) | If too many arguments are provided, it returns |
Applies concrete arguments to a set of Parameters
.
paramType :: Parameters -> Int -> Maybe ParameterType Source #
argType
gets called when the user tries to autocomplete an i
th argument (zero-indexed).
todo: would be nice if we could alert the user if they try to autocomplete
past the end. It would also be nice if
data FZFResolver Source #
Constructors
FZFResolver | |
Fields
|
Instances
Show FZFResolver Source # | |
Defined in Unison.CommandLine.FZFResolvers Methods showsPrec :: Int -> FZFResolver -> ShowS # show :: FZFResolver -> String # showList :: [FZFResolver] -> ShowS # |
data Visibility Source #
Instances
Show Visibility Source # | |
Defined in Unison.CommandLine.InputPattern Methods showsPrec :: Int -> Visibility -> ShowS # show :: Visibility -> String # showList :: [Visibility] -> ShowS # | |
Eq Visibility Source # | |
Defined in Unison.CommandLine.InputPattern | |
Ord Visibility Source # | |
Defined in Unison.CommandLine.InputPattern Methods compare :: Visibility -> Visibility -> Ordering # (<) :: Visibility -> Visibility -> Bool # (<=) :: Visibility -> Visibility -> Bool # (>) :: Visibility -> Visibility -> Bool # (>=) :: Visibility -> Visibility -> Bool # max :: Visibility -> Visibility -> Visibility # min :: Visibility -> Visibility -> Visibility # |
Currently Unused
minArgs :: Parameters -> Int Source #
unionSuggestions :: forall m v a. MonadIO m => [String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion]] -> String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion] Source #
Union suggestions from all possible completions
suggestionFallbacks :: forall m v a. MonadIO m => [String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion]] -> String -> Codebase m v a -> AuthenticatedHttpClient -> ProjectPath -> m [Completion] Source #
Try the first completer, if it returns no suggestions, try the second, etc.