{"id":13903003,"url":"https://github.com/bfontaine/grape","last_synced_at":"2025-04-09T23:18:18.000Z","repository":{"id":57713239,"uuid":"217748933","full_name":"bfontaine/grape","owner":"bfontaine","description":":grapes: Syntax-aware grep-like for Clojure","archived":false,"fork":false,"pushed_at":"2023-01-31T10:00:51.000Z","size":231,"stargazers_count":152,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T23:18:13.559Z","etag":null,"topics":["cli","clojure-library","code-search","pattern-matching"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bfontaine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-26T18:01:25.000Z","updated_at":"2025-03-20T12:44:42.000Z","dependencies_parsed_at":"2023-02-16T18:02:20.845Z","dependency_job_id":null,"html_url":"https://github.com/bfontaine/grape","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fgrape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fgrape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fgrape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fgrape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bfontaine","download_url":"https://codeload.github.com/bfontaine/grape/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125593,"owners_count":21051771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","clojure-library","code-search","pattern-matching"],"created_at":"2024-08-06T22:01:33.260Z","updated_at":"2025-04-09T23:18:17.977Z","avatar_url":"https://github.com/bfontaine.png","language":"Clojure","funding_links":[],"categories":["cli"],"sub_categories":[],"readme":"\u003cimg align=\"right\" width=\"150\" alt=\"grapes.\" src=\"./doc/grapes.png\"/\u003e\n\n# Grape\n**Grape** is a syntax-aware `grep`-like utility for Clojure code. It allows you to search for code\npatterns using Clojure data structures.\n\nNote: this project is not maintained. It works as is, but I don’t use Clojure these days and I don’t have the\ntime/motivation to add more features. If you wish to improve the project, please contact me so I can give you commit\naccess. Otherwise, see [Grasp](https://github.com/borkdude/grasp) for a similar and more-maintained tool.\n\n## Command-line\n```\n$ grape [options] \u003cpattern\u003e [\u003cfile\u003e ...]\n```\n\nFor example, to find all usages of `map` called with three arguments in `grape`’s own code:\n\n```\ngrape --unindent '(map $ $ $)' src\n```\nOutput:\n```\nsrc/grape/impl/match.clj:\n29:(map match?\n        trees\n        patterns)\n\nsrc/grape/cli.clj:\n137:(map #(when (= %1 %2) %1) prefix line-prefix)\n\n```\n\nOptions:\n* `-c`, `--count`: show the total matches count and exit.\n* `-F`, `--no-filenames`: by default, `grape` shows the matching filenames when run on multiple files. This option\n  disables that.\n* `-u`, `--unindent`: un-indent matches.\n* `--line-numbers first|all|none`: control line numbers. The default is `first`, i.e. only the first line of each match\n  is prefixed by its line number. `all` shows all line numbers; `none` remove them.\n* `-n`, `--all-line-numbers`: alias for `--line-numbers all`\n* `-N`, `--no-line-numbers`: alias for `--line-numbers none`\n* `--inline`: force matches on one line. Note this doesn’t change multi-line strings.\n\nRun `grape --help` to show all options.\n\n### Install\nEither get the standalone binary (faster) or a jar from the [Releases page][releases].\n\n[releases]: https://github.com/bfontaine/grape/releases\n\nIf you have [Homebrew](https://brew.sh), you can install it like so:\n```bash\nbrew install bfontaine/utils/grape\n```\n\nThanks to @ngrunwald, there’s also an Arch Linux [`grape-bin`][arch] package. For example, if you\nuse `yay`:\n\n```bash\nyay -S grape-bin\n```\n\n[arch]: https://aur.archlinux.org/packages/grape-bin/\n\n## Library\n[![Clojars Project](https://img.shields.io/clojars/v/bfontaine/grape.svg)](https://clojars.org/bfontaine/grape)\n\n\n```clojure\n(require '[grape.core :as g])\n\n(def my-code (slurp \"myfile.clj\"))\n\n;; Find all occurrences of map called with three arguments\n(g/find-codes my-code (g/pattern \"(map $ $ $)\"))\n\n;; Find all occurrences of (condp = ...)\n(g/find-codes my-code (g/pattern \"(condp = $\u0026)\"))\n\n;; Find all occurrences of `if` with no `else` clause\n(g/find-codes my-code (g/pattern \"(if $ $)\"))\n; =\u003e ({:match \"(if …)\", :meta {…}}, …)\n```\n\nMatches are map with a `:match` key that contains a string with the matching\ncode and a `:meta` key with line/column metadata which you can use to locate\nthe code in your file.\n\n## Patterns\nA pattern is any valid Clojure expression. It can contain some special symbols\nthat are interpreted as wildcards.\n\nComments, whitespaces, and discard reader macros (`#_`) are ignored when\nmatching.\n\n### Wildcards\n* `$`: any expression.\n* `$\u0026`: any number of expressions, including zero. `(f $\u0026)` matches `(f)`,\n  `(f 1)`, `(f 1 2)`, etc.\n* `$string`, `$list`, etc: any expression of the given type.\n\n[See the full patterns documentation](./doc/Patterns.md). [See more examples](./doc/Examples.md).\n\nWildcards can be combined: `#{$ $\u0026}` matches a set with at least one element.\n\n[parcera]: https://github.com/carocad/parcera#parcera\n\n## License\n\nCopyright © 2019-2023 Baptiste Fontaine\n\nThis program and the accompanying materials are made available under the terms\nof the Eclipse Public License 2.0 which is available at\nhttp://www.eclipse.org/legal/epl-2.0.\n\nThis Source Code may also be made available under the following Secondary\nLicenses when the conditions for such availability set forth in the Eclipse\nPublic License, v. 2.0 are satisfied: GNU General Public License as published\nby the Free Software Foundation, either version 2 of the License, or (at your\noption) any later version, with the GNU Classpath Exception which is available\nat https://www.gnu.org/software/classpath/license.html.\n\n## See also\n* [Grasp](https://github.com/borkdude/grasp), to grep Clojure code using clojure.spec regexes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfontaine%2Fgrape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbfontaine%2Fgrape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfontaine%2Fgrape/lists"}