mskelton / flashlight

Find usages of imported symbols in your codebase.

Home Page:https://mskelton.dev/bytes/better-code-search-with-flashlight

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flashlight

CLI tool to help you analyze code usage in your project.

Flashlight allows you to perform searches that would be difficult with normal string or regex searching such as:

  • Find all imports from react that imported useMemo
  • Find all <Button> tags with the attribute type="primary"

Regex searches can work for this at times, but it becomes very complex when imports or tags span multiple lines. Flashlight provides a much easier way to perform these searches.

Installation

You can install Flashlight by running the install script which will download the latest release.

curl -LSfs https://go.mskelton.dev/flashlight/install | sh

Or you can build from source.

git clone git@github.com:mskelton/flashlight.git
cd flashlight
cargo install --path .

Commands

imports

Searches for all imports for a given import source.

flashlight imports react

You can also search for a specific import specifier.

flashlight imports react useState

tags

Searches for all JSX elements with the given name.

flashlight tags Button

You can also search for elements with a specific attribute or attribute/value pair.

flashlight tags Button variant
flashlight tags Button variant=primary

Flags

Change working directory

By default, flashlight uses the current working directory to search. You can change the working directory using the --cwd argument.

flashlight --cwd ./packages/a imports react

Format

You can customize the output format based on your use case. The supported formats are:

  • default - The default console format
  • json - Formats the output as JSON
  • quickfix - Formats the output as a Vim quickfix list (alias vi)
flashlight --format json imports react

About

Find usages of imported symbols in your codebase.

https://mskelton.dev/bytes/better-code-search-with-flashlight

License:ISC License


Languages

Language:Rust 73.7%Language:Shell 26.3%