| 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 {}
- data Argument
- 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
- = FetchOptions OptionFetcher
- | DefaultFZFFileSearch
- data Visibility
- parseArgs :: String -> Maybe [CliArg]
- data CliArg
- data NumberedArg
- renderCliArg :: CliArg -> String
- renderCliArgUnquoted :: CliArg -> String
- 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 | |
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).
Constructors
| RawArg String | |
| StructuredArg StructuredArgument |
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 ith 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
| FetchOptions OptionFetcher | |
| DefaultFZFFileSearch |
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 # | |
Parse Arguments
parseArgs :: String -> Maybe [CliArg] Source #
Like parseArgs, but indicates whether each argument was quoted, and also whether the quote was terminated..
This is for things like tab-completion where the original string is important.
Constructors
| NumberedArg NumberedArg | |
| QuotedArg String Bool | |
| UnquotedArg String |
data NumberedArg Source #
Constructors
| NumberedSingle Int | |
| NumberedRange Int Int | |
| NumberedAfterStart Int | |
| NumberedBeforeEnd Int |
Instances
| Show NumberedArg Source # | |
Defined in Unison.CommandLine.InputPattern Methods showsPrec :: Int -> NumberedArg -> ShowS # show :: NumberedArg -> String # showList :: [NumberedArg] -> ShowS # | |
| Eq NumberedArg Source # | |
Defined in Unison.CommandLine.InputPattern | |
renderCliArgUnquoted :: CliArg -> String Source #
Like renderCliArg, but does not include quotes regardless of whether the argument was quoted.
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.