unison-cli-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.CommandLine.InputPattern

Synopsis

Documentation

data InputPattern Source #

Constructors

InputPattern 

Fields

  • patternName :: String
     
  • aliases :: [String]
     
  • visibility :: Visibility

    Allow hiding certain commands when debugging or work-in-progress

  • params :: Parameters
     
  • help :: Pretty ColorText
     
  • parse :: Arguments -> Either (Pretty ColorText) Input

    Parse the arguments and return either an error message or a command Input.

    The input list is always a valid length for the pattern. It may be necessary to have a catch-all case for coverage, but the implementation can assume that, say, a OnePlus parameter will always be provided at least one argument.

    NB: This function should return Left only on failure. For commands (like $sel:help:InputPattern) that simply produce formatted output, use `pure . Input.CreateMessage`. The failure output should be fully formatted (using wrap, etc.), but shouldn’t include any general error components like a warning flag or the full help message, and shouldn’t plan for the context it is being output to (e.g., don’t indentN the entire message).

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

data TrailingParameters Source #

Constructors

Optional [Parameter] (Maybe Parameter)

Optional args followed by a possibly-empty catch-all

OnePlus Parameter

A catch-all that requires at least one value

data Parameters Source #

The Parameters for an InputPattern are roughly

[required …] ([optional …] [catchAll] | NonEmpty catchAll)

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.

foldParamsWithM Source #

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 Left, with the arguments that couldn’t be assigned to a parameter. Otherwise, it returns a tuple of the Parameters that could still be applied to additional arguments (e.g., via fuzzy completion) and the final result. If the returned Parameters has remaining required arguments, they must either be provided somehow (e.g., another call to this function or fuzzy completion) or result in a “not enough arguments” error.

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

FZFResolver 

Fields

Instances

Instances details
Show FZFResolver Source # 
Instance details

Defined in Unison.CommandLine.FZFResolvers

Currently Unused

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.