Skip to content

Commit

Permalink
Show the number of matches found matching query
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Jan 4, 2025
1 parent fa57e47 commit 7f1f5be
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cabal-install/src/Distribution/Client/CmdTarget.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ targetAction flags@NixStyleFlags{..} ts globalFlags = do
Nothing
targetSelectors

printTargetForms verbosity targets elaboratedPlan
printTargetForms verbosity targetStrings targets elaboratedPlan
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
targetStrings = if null ts then ["all"] else ts
Expand All @@ -183,14 +183,21 @@ targetAction flags@NixStyleFlags{..} ts globalFlags = do
reportBuildTargetProblems :: Verbosity -> [TargetProblem'] -> IO a
reportBuildTargetProblems verbosity = reportTargetProblems verbosity "target"

printTargetForms :: Verbosity -> TargetsMap -> ElaboratedInstallPlan -> IO ()
printTargetForms verbosity targets elaboratedPlan =
printTargetForms :: Verbosity -> [String] -> TargetsMap -> ElaboratedInstallPlan -> IO ()
printTargetForms verbosity targetStrings targets elaboratedPlan =
noticeDoc verbosity $
vcat
[ text "Fully qualified target forms" Pretty.<> colon
, nest 1 $ vcat [text "-" <+> text tf | tf <- targetForms]
, found
]
where
found =
let n = length targets
t = if n == 1 then "target" else "targets"
query = intercalate ", " targetStrings
in text "Found" <+> int n <+> text t <+> text "matching" <+> text query Pretty.<> char '.'

localPkgs =
[x | Configured x@ElaboratedConfiguredPackage{elabLocalToProject = True} <- InstallPlan.toList elaboratedPlan]

Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Target/cabal.all-benches.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Resolving dependencies...
Fully qualified target forms:
- a:bench:a-bench
- b:bench:b-bench
Found 2 targets matching all:benches.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Fully qualified target forms:
- b:lib:b
- b:lib:b-sublib
- c:lib:c
Found 9 targets matching all.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Fully qualified target forms:
- b:lib:b-sublib
- b:test:b-test
- c:lib:c
Found 9 targets matching all.
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Target/cabal.all-exes.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Resolving dependencies...
Fully qualified target forms:
- a:exe:a-exe
- b:exe:b-exe
Found 2 targets matching all:exes.
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Target/cabal.all-tests.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Resolving dependencies...
Fully qualified target forms:
- a:test:a-test
- b:test:b-test
Found 2 targets matching all:tests.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ Configuration is affected by the following files:
Resolving dependencies...
Fully qualified target forms:
- a:bench:a-bench
Found 1 target matching a:bench:a-bench.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:bench:a-bench
Found 1 target matching bench:a-bench.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:bench:a-bench
Found 1 target matching a:a-bench.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ Configuration is affected by the following files:
Resolving dependencies...
Fully qualified target forms:
- a:exe:a-exe
Found 1 target matching a:exe:a-exe.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:exe:a-exe
Found 1 target matching exe:a-exe.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:exe:a-exe
Found 1 target matching a:a-exe.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ Configuration is affected by the following files:
Resolving dependencies...
Fully qualified target forms:
- a:lib:a
Found 1 target matching a:lib:a.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:lib:a
Found 1 target matching lib:a.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:lib:a
Found 1 target matching a:a.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ Configuration is affected by the following files:
Resolving dependencies...
Fully qualified target forms:
- a:test:a-test
Found 1 target matching a:test:a-test.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:test:a-test
Found 1 target matching test:a-test.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:test:a-test
Found 1 target matching a:a-test.
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/Target/cabal.ctype-target.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ Resolving dependencies...
Fully qualified target forms:
- a:lib:a
- a:lib:a-sublib
Found 2 targets matching a:libs.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:exe:a-exe
Found 1 target matching a:exes.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:test:a-test
Found 1 target matching a:tests.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Fully qualified target forms:
- a:bench:a-bench
Found 1 target matching a:benches.
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Target/cabal.default-all.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Fully qualified target forms:
- b:lib:b
- b:lib:b-sublib
- c:lib:c
Found 7 targets matching all.
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Target/cabal.everything.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Fully qualified target forms:
- b:lib:b-sublib
- b:test:b-test
- c:lib:c
Found 11 targets matching all.
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Target/cabal.explicit-all.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Fully qualified target forms:
- b:lib:b
- b:lib:b-sublib
- c:lib:c
Found 7 targets matching all.
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/Target/cabal.package-target.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Fully qualified target forms:
- a:exe:a-exe
- a:lib:a
- a:lib:a-sublib
Found 3 targets matching a.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Expand All @@ -16,3 +17,4 @@ Fully qualified target forms:
- a:lib:a
- a:lib:a-sublib
- a:test:a-test
Found 5 targets matching a.
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/Target/cabal.path-target.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Fully qualified target forms:
- a:exe:a-exe
- a:lib:a
- a:lib:a-sublib
Found 3 targets matching dir-a/.
# cabal v2-target
Configuration is affected by the following files:
- cabal.project
Expand All @@ -16,3 +17,4 @@ Fully qualified target forms:
- a:lib:a
- a:lib:a-sublib
- a:test:a-test
Found 5 targets matching dir-a/.

0 comments on commit 7f1f5be

Please sign in to comment.