Function: bazel--read-target-pattern

bazel--read-target-pattern is a natively compiled function defined in bazel.el.

Signature

(bazel--read-target-pattern PROMPT ONLY-TESTS)

Documentation

Read a Bazel build target pattern from the minibuffer.

PROMPT is the minibuffer prompt without trailing colon; it is run through ‘format-prompt’. If ONLY-TESTS is non-nil, look only for test targets.

Source Code

;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--read-target-pattern (prompt only-tests)
  "Read a Bazel build target pattern from the minibuffer.
PROMPT is the minibuffer prompt without trailing colon; it is run
through ‘format-prompt’.  If ONLY-TESTS is non-nil, look only for test
targets."
  (declare (ftype (function (string t) string)))
  (cl-check-type prompt string)
  (let* ((file-name
          (or buffer-file-name default-directory
              (user-error "Buffer doesn’t visit a file or directory")))
         (repository-root (or (bazel--repository-root file-name)
                              (user-error "File is not in a Bazel repository")))
         (directory (or (bazel--package-directory file-name repository-root)
                        (user-error "File is not in a Bazel package")))
         (package-name (or (bazel--package-name directory repository-root)
                           (user-error "File is not in a Bazel package")))
         (table (bazel--target-completion-table :pattern only-tests))
         (default (bazel--target-completion-default
                   buffer-file-name repository-root package-name only-tests)))
    (completing-read (format-prompt prompt default) table nil nil nil
                     'bazel-target-history default)))