Skip to content

Commit

Permalink
Merge pull request #4595 from unisonweb/cp/remove-globbing
Browse files Browse the repository at this point in the history
Remove UCM globbing as a feature
  • Loading branch information
aryairani authored Jan 9, 2024
2 parents 3b9b813 + 90d89ac commit d34c532
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 385 deletions.
19 changes: 2 additions & 17 deletions unison-cli/src/Unison/CommandLine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module Unison.CommandLine
where

import Control.Concurrent (forkIO, killThread)
import Control.Lens (ifor)
import Control.Monad.Except
import Control.Monad.Trans.Except
import Data.Configurator (autoConfig, autoReload)
Expand All @@ -50,7 +49,6 @@ import Unison.Codebase.Path qualified as Path
import Unison.Codebase.Watch qualified as Watch
import Unison.CommandLine.FZFResolvers qualified as FZFResolvers
import Unison.CommandLine.FuzzySelect qualified as Fuzzy
import Unison.CommandLine.Globbing qualified as Globbing
import Unison.CommandLine.InputPattern (InputPattern (..))
import Unison.CommandLine.InputPattern qualified as InputPattern
import Unison.Parser.Ann (Ann)
Expand Down Expand Up @@ -122,7 +120,7 @@ nothingTodo = emojiNote "😶"
parseInput ::
Codebase IO Symbol Ann ->
IO (Branch0 IO) ->
-- | Current path from root, used to expand globs
-- | Current path from root
Path.Absolute ->
-- | Numbered arguments
[String] ->
Expand All @@ -147,20 +145,7 @@ parseInput codebase getRoot currentPath numberedArgs patterns segments = runExce
let expandedNumbers :: [String]
expandedNumbers =
foldMap (expandNumber numberedArgs) args
expandedGlobs <- ifor expandedNumbers $ \i arg -> do
if Globbing.containsGlob arg
then do
rootBranch <- liftIO getRoot
let targets = case InputPattern.argType pat i of
Just argT -> InputPattern.globTargets argT
Nothing -> mempty
case Globbing.expandGlobs targets rootBranch currentPath arg of
-- No globs encountered
Nothing -> pure [arg]
Just [] -> throwE $ "No matches for: " <> fromString arg
Just matches -> pure matches
else pure [arg]
lift (fzfResolve codebase projCtx getCurrentBranch0 pat (concat expandedGlobs)) >>= \case
lift (fzfResolve codebase projCtx getCurrentBranch0 pat expandedNumbers) >>= \case
Left (NoFZFResolverForArgumentType _argDesc) -> throwError help
Left (NoFZFOptions argDesc) -> throwError (noCompletionsMessage argDesc)
Left FZFCancelled -> pure Nothing
Expand Down
148 changes: 0 additions & 148 deletions unison-cli/src/Unison/CommandLine/Globbing.hs

This file was deleted.

4 changes: 0 additions & 4 deletions unison-cli/src/Unison/CommandLine/InputPattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import Unison.Codebase (Codebase)
import Unison.Codebase.Editor.Input (Input (..))
import Unison.Codebase.Path as Path
import Unison.CommandLine.FZFResolvers (FZFResolver (..))
import Unison.CommandLine.Globbing qualified as Globbing
import Unison.Prelude
import Unison.Util.ColorText qualified as CT
import Unison.Util.Monoid (foldMapM)
Expand Down Expand Up @@ -70,9 +69,6 @@ data ArgumentType = ArgumentType
AuthenticatedHttpClient ->
Path.Absolute -> -- Current path
m [Line.Completion],
-- | Select which targets glob patterns may expand into for this argument.
-- An empty set disables globbing.
globTargets :: Set Globbing.TargetType,
-- | If an argument is marked as required, but not provided, the fuzzy finder will be triggered if
-- available.
fzfResolver :: Maybe FZFResolver
Expand Down
23 changes: 0 additions & 23 deletions unison-cli/src/Unison/CommandLine/InputPatterns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import Unison.Codebase.Verbosity qualified as Verbosity
import Unison.CommandLine
import Unison.CommandLine.Completion
import Unison.CommandLine.FZFResolvers qualified as Resolvers
import Unison.CommandLine.Globbing qualified as Globbing
import Unison.CommandLine.InputPattern (ArgumentType (..), InputPattern (InputPattern), IsOptional (..), unionSuggestions)
import Unison.CommandLine.InputPattern qualified as I
import Unison.HashQualified qualified as HQ
Expand Down Expand Up @@ -1857,7 +1856,6 @@ topicNameArg =
in ArgumentType
{ typeName = "topic",
suggestions = \q _ _ _ -> pure (exactComplete q $ topics),
globTargets = mempty,
fzfResolver = Just $ Resolvers.fuzzySelectFromList (Text.pack <$> topics)
}

Expand All @@ -1866,7 +1864,6 @@ codebaseServerNameArg =
ArgumentType
{ typeName = "codebase-server",
suggestions = \_ _ _ _ -> pure [],
globTargets = mempty,
fzfResolver = Nothing
}

Expand Down Expand Up @@ -2814,7 +2811,6 @@ branchInputPattern =
ArgumentType
{ typeName = "new-branch",
suggestions = \_ _ _ _ -> pure [],
globTargets = mempty,
fzfResolver = Nothing
}
suggestionsConfig =
Expand Down Expand Up @@ -3082,7 +3078,6 @@ commandNameArg =
in ArgumentType
{ typeName = "command",
suggestions = \q _ _ _ -> pure (exactComplete q options),
globTargets = mempty,
fzfResolver = Just $ Resolvers.fuzzySelectFromList (Text.pack <$> options)
}

Expand All @@ -3091,7 +3086,6 @@ exactDefinitionArg =
ArgumentType
{ typeName = "definition",
suggestions = \q cb _http p -> Codebase.runTransaction cb (prefixCompleteTermOrType q p),
globTargets = Set.fromList [Globbing.Term, Globbing.Type],
fzfResolver = Just Resolvers.definitionResolver
}

Expand All @@ -3100,7 +3094,6 @@ fuzzyDefinitionQueryArg =
ArgumentType
{ typeName = "fuzzy definition query",
suggestions = \q cb _http p -> Codebase.runTransaction cb (prefixCompleteTermOrType q p),
globTargets = Set.fromList [Globbing.Term, Globbing.Type],
fzfResolver = Just Resolvers.definitionResolver
}

Expand All @@ -3112,7 +3105,6 @@ exactDefinitionTypeQueryArg =
ArgumentType
{ typeName = "type definition query",
suggestions = \q cb _http p -> Codebase.runTransaction cb (prefixCompleteType q p),
globTargets = Set.fromList [Globbing.Type],
fzfResolver = Just Resolvers.typeDefinitionResolver
}

Expand All @@ -3121,7 +3113,6 @@ exactDefinitionTypeOrTermQueryArg =
ArgumentType
{ typeName = "type or term definition query",
suggestions = \q cb _http p -> Codebase.runTransaction cb (prefixCompleteTermOrType q p),
globTargets = Set.fromList [Globbing.Term],
fzfResolver = Just Resolvers.definitionResolver
}

Expand All @@ -3130,7 +3121,6 @@ exactDefinitionTermQueryArg =
ArgumentType
{ typeName = "term definition query",
suggestions = \q cb _http p -> Codebase.runTransaction cb (prefixCompleteTerm q p),
globTargets = Set.fromList [Globbing.Term],
fzfResolver = Just Resolvers.termDefinitionResolver
}

Expand All @@ -3139,7 +3129,6 @@ patchArg =
ArgumentType
{ typeName = "patch",
suggestions = \q cb _http p -> Codebase.runTransaction cb (prefixCompletePatch q p),
globTargets = Set.fromList [],
fzfResolver = Nothing
}

Expand All @@ -3148,7 +3137,6 @@ namespaceArg =
ArgumentType
{ typeName = "namespace",
suggestions = \q cb _http p -> Codebase.runTransaction cb (prefixCompleteNamespace q p),
globTargets = Set.fromList [Globbing.Namespace],
fzfResolver = Just Resolvers.namespaceResolver
}

Expand All @@ -3164,7 +3152,6 @@ namespaceOrProjectBranchArg config =
[ projectAndOrBranchSuggestions config,
namespaceSuggestions
],
globTargets = mempty,
fzfResolver = Just Resolvers.projectOrBranchResolver
}

Expand All @@ -3176,7 +3163,6 @@ namespaceOrDefinitionArg =
namespaces <- prefixCompleteNamespace q p
termsTypes <- prefixCompleteTermOrType q p
pure (List.nubOrd $ namespaces <> termsTypes),
globTargets = Set.fromList [Globbing.Namespace, Globbing.Term, Globbing.Type],
fzfResolver =
Just Resolvers.namespaceOrDefinitionResolver
}
Expand All @@ -3190,7 +3176,6 @@ newNameArg =
ArgumentType
{ typeName = "new-name",
suggestions = \q cb _http p -> Codebase.runTransaction cb (prefixCompleteNamespace q p),
globTargets = mempty,
fzfResolver = Nothing
}

Expand All @@ -3199,7 +3184,6 @@ noCompletionsArg =
ArgumentType
{ typeName = "word",
suggestions = noCompletions,
globTargets = mempty,
fzfResolver = Nothing
}

Expand All @@ -3208,7 +3192,6 @@ filePathArg =
ArgumentType
{ typeName = "file-path",
suggestions = noCompletions,
globTargets = mempty,
fzfResolver = Nothing
}

Expand All @@ -3227,7 +3210,6 @@ gitUrlArg =
"gls" -> complete "git([email protected]:"
"bbs" -> complete "git([email protected]:"
_ -> pure [],
globTargets = mempty,
fzfResolver = Nothing
}

Expand All @@ -3247,7 +3229,6 @@ remoteNamespaceArg =
"bbs" -> complete "git([email protected]:"
_ -> do
sharePathCompletion http input,
globTargets = mempty,
fzfResolver = Nothing
}

Expand Down Expand Up @@ -3487,7 +3468,6 @@ projectAndBranchNamesArg config =
ArgumentType
{ typeName = "project-and-branch-names",
suggestions = projectAndOrBranchSuggestions config,
globTargets = Set.empty,
fzfResolver = Just Resolvers.projectAndOrBranchArg
}

Expand All @@ -3497,7 +3477,6 @@ projectBranchNameArg config =
ArgumentType
{ typeName = "project-branch-name",
suggestions = projectAndOrBranchSuggestions config,
globTargets = Set.empty,
fzfResolver = Just Resolvers.projectBranchResolver
}

Expand All @@ -3507,7 +3486,6 @@ projectBranchNameWithOptionalProjectNameArg =
ArgumentType
{ typeName = "project-branch-name-with-optional-project-name",
suggestions = \_ _ _ _ -> pure [],
globTargets = Set.empty,
fzfResolver = Just Resolvers.projectBranchResolver
}

Expand All @@ -3521,7 +3499,6 @@ projectNameArg =
Codebase.runTransaction codebase do
Queries.loadAllProjectsBeginningWith (Just input)
pure $ map projectToCompletion projects,
globTargets = Set.empty,
fzfResolver = Just $ Resolvers.multiResolver [Resolvers.projectNameOptions]
}
where
Expand Down
Loading

0 comments on commit d34c532

Please sign in to comment.