Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions docs/reference/cli-options.md

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/usage/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Excludes entire repositories from the results. The org prefix is optional.
```bash
# Short form (recommended)
github-code-search "useFeatureFlag" --org fulll \
--exclude-repositories legacy-monolith,archived-app
--exclude-repositories legacy-app,archived-app

# Long form (also accepted)
github-code-search "useFeatureFlag" --org fulll \
--exclude-repositories fulll/legacy-monolith,fulll/archived-app
--exclude-repositories fulll/legacy-app,fulll/archived-app
```

Pass a comma-separated list. There is no limit on the number of repos you can exclude.
Expand All @@ -27,17 +27,17 @@ The short form (without the org prefix) is recommended — it is easier to read
Excludes individual code extracts. The format is `repoName:path/to/file:matchIndex`.

```bash
# Exclude the first extract (index 0) of src/flags.ts in billing-api
# Exclude the first extract (index 0) of src/flags.ts in service-b
github-code-search "useFeatureFlag" --org fulll \
--exclude-extracts billing-api:src/flags.ts:0
--exclude-extracts service-b:src/flags.ts:0

# Exclude multiple extracts
github-code-search "useFeatureFlag" --org fulll \
--exclude-extracts billing-api:src/flags.ts:0,auth-service:tests/unit/featureFlags.test.ts:1
--exclude-extracts service-b:src/flags.ts:0,service-a:tests/unit/featureFlags.test.ts:1

# Long form (also accepted)
github-code-search "useFeatureFlag" --org fulll \
--exclude-extracts fulll/billing-api:src/flags.ts:0
--exclude-extracts fulll/service-b:src/flags.ts:0
```

The index is **zero-based** and corresponds to the position of the file in the GitHub API result list for that repository — not the position of the match within the file itself. Each `(repo, file)` pair is one extract with a unique index.
Expand Down Expand Up @@ -84,8 +84,8 @@ All four flags can be combined freely:
github-code-search "useFeatureFlag" --org fulll \
--include-archived \
--exclude-template-repositories \
--exclude-repositories legacy-monolith \
--exclude-extracts billing-api:src/flags.ts:0
--exclude-repositories legacy-app \
--exclude-extracts service-b:src/flags.ts:0
```

## In-TUI filtering
Expand Down
16 changes: 8 additions & 8 deletions docs/usage/interactive-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ github-code-search "useFeatureFlag" --org fulll
3 repos · 4 files
← / → fold/unfold ↑ / ↓ navigate spc select a all n none f filter h help ↵ confirm q quit

▸ fulll/billing-api 3 matches
▾ ✓ fulll/auth-service 2 matches
▸ fulll/service-b 3 matches
▾ ✓ fulll/service-a 2 matches
✓ src/middlewares/featureFlags.ts
…const flag = useFeatureFlag('new-onboarding'); if (!flag) return next();…
✓ tests/unit/featureFlags.test.ts
…expect(useFeatureFlag('new-onboarding')).toBe(true);…
▸ fulll/legacy-monolith 1 match
▸ fulll/legacy-app 1 match
```

- `▸` — folded repo (extracts hidden)
Expand Down Expand Up @@ -167,18 +167,18 @@ After pressing `Enter`:
```text
2 repos · 2 files selected

- **fulll/auth-service** (1 match)
- [ ] [src/middlewares/featureFlags.ts:2:19](https://github.com/fulll/auth-service/blob/main/src/middlewares/featureFlags.ts#L2)
- **fulll/billing-api** (1 match)
- [ ] [src/flags.ts:3:14](https://github.com/fulll/billing-api/blob/main/src/flags.ts#L3)
- **fulll/service-a** (1 match)
- [ ] [src/middlewares/featureFlags.ts:2:19](https://github.com/fulll/service-a/blob/main/src/middlewares/featureFlags.ts#L2)
- **fulll/service-b** (1 match)
- [ ] [src/flags.ts:3:14](https://github.com/fulll/service-b/blob/main/src/flags.ts#L3)
```

<details>
<summary>replay command</summary>

```bash
github-code-search "useFeatureFlag" --org fulll --no-interactive \
--exclude-repositories legacy-monolith
--exclude-repositories legacy-app
```

</details>
Expand Down
20 changes: 10 additions & 10 deletions docs/usage/non-interactive-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ $ CI=true github-code-search "useFeatureFlag" --org fulll

3 repos · 5 files selected

- **fulll/auth-service** (2 matches)
- [ ] [src/middlewares/featureFlags.ts:2:19](https://github.com/fulll/auth-service/blob/main/src/middlewares/featureFlags.ts#L2): `useFeatureFlag`
- [ ] [tests/unit/featureFlags.test.ts:1:8](https://github.com/fulll/auth-service/blob/main/tests/unit/featureFlags.test.ts#L1): `useFeatureFlag`
- **fulll/billing-api** (2 matches)
- [ ] [src/flags.ts:3:14](https://github.com/fulll/billing-api/blob/main/src/flags.ts#L3): `useFeatureFlag`
- [ ] [src/routes/invoices.ts:1:1](https://github.com/fulll/billing-api/blob/main/src/routes/invoices.ts#L1): `useFeatureFlag`
- **fulll/frontend-app** (1 match)
- [ ] [src/hooks/useFeatureFlag.ts:1:1](https://github.com/fulll/frontend-app/blob/main/src/hooks/useFeatureFlag.ts#L1): `useFeatureFlag`
- **fulll/service-a** (2 matches)
- [ ] [src/middlewares/featureFlags.ts:2:19](https://github.com/fulll/service-a/blob/main/src/middlewares/featureFlags.ts#L2): `useFeatureFlag`
- [ ] [tests/unit/featureFlags.test.ts:1:8](https://github.com/fulll/service-a/blob/main/tests/unit/featureFlags.test.ts#L1): `useFeatureFlag`
- **fulll/service-b** (2 matches)
- [ ] [src/flags.ts:3:14](https://github.com/fulll/service-b/blob/main/src/flags.ts#L3): `useFeatureFlag`
- [ ] [src/routes/invoices.ts:1:1](https://github.com/fulll/service-b/blob/main/src/routes/invoices.ts#L1): `useFeatureFlag`
- **fulll/app-a** (1 match)
- [ ] [src/hooks/useFeatureFlag.ts:1:1](https://github.com/fulll/app-a/blob/main/src/hooks/useFeatureFlag.ts#L1): `useFeatureFlag`
```

<details>
Expand All @@ -66,8 +66,8 @@ At the end of every interactive session, `github-code-search` prints a **replay

```bash
github-code-search "useFeatureFlag" --org fulll --no-interactive \
--exclude-repositories legacy-monolith \
--exclude-extracts auth-service:tests/unit/featureFlags.test.ts:0
--exclude-repositories legacy-app \
--exclude-extracts service-a:tests/unit/featureFlags.test.ts:0
```

This is the recommended bridge between an interactive exploration session and a reproducible CI step.
Expand Down
22 changes: 11 additions & 11 deletions docs/usage/output-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ github-code-search "useFeatureFlag" --org fulll --format markdown --no-interacti

3 repos · 4 files selected

- **fulll/auth-service** (2 matches)
- **fulll/service-a** (2 matches)
- [ ] [src/middlewares/featureFlags.ts:2:19](...): `useFeatureFlag`
- [ ] [tests/unit/featureFlags.test.ts:1:8](...): `useFeatureFlag`
- **fulll/billing-api** (1 match)
- **fulll/service-b** (1 match)
- [ ] [src/flags.ts:3:14](...): `useFeatureFlag`
- **fulll/frontend-app** (1 match)
- **fulll/app-a** (1 match)
- [ ] [src/hooks/useFeatureFlag.ts:1:1](...): `useFeatureFlag`
```

Expand Down Expand Up @@ -67,11 +67,11 @@ github-code-search "useFeatureFlag" --org fulll --format json --no-interactive
"selection": { "repos": 1, "matches": 1 },
"results": [
{
"repo": "fulll/auth-service",
"repo": "fulll/service-a",
"matches": [
{
"path": "src/middlewares/featureFlags.ts",
"url": "https://github.com/fulll/auth-service/blob/main/src/middlewares/featureFlags.ts",
"url": "https://github.com/fulll/service-a/blob/main/src/middlewares/featureFlags.ts",
"line": 2,
"col": 19,
"matchedText": "useFeatureFlag"
Expand Down Expand Up @@ -106,9 +106,9 @@ github-code-search "useFeatureFlag" --org fulll \
```text
# Results for "useFeatureFlag"

fulll/auth-service
fulll/billing-api
fulll/frontend-app
fulll/service-a
fulll/service-b
fulll/app-a
```

::: details replay command
Expand All @@ -132,9 +132,9 @@ github-code-search "useFeatureFlag" --org fulll \
"org": "fulll",
"selection": { "repos": 3, "matches": 5 },
"results": [
{ "repo": "fulll/auth-service" },
{ "repo": "fulll/billing-api" },
{ "repo": "fulll/frontend-app" }
{ "repo": "fulll/service-a" },
{ "repo": "fulll/service-b" },
{ "repo": "fulll/app-a" }
],
"replayCommand": "# Replay:\ngithub-code-search \"useFeatureFlag\" --org fulll --format json --no-interactive --output-type repo-only"
}
Expand Down
39 changes: 29 additions & 10 deletions docs/usage/search-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,40 @@ Searches for the literal string `useFeatureFlag` across all repositories in the

GitHub code search supports a set of qualifiers you can combine with your keyword:

| Qualifier | Description | Example |
| --------------------- | ---------------------------------------------------------------- | ------------------------------------ |
| `language:<lang>` | Filter by programming language | `useFeatureFlag language:TypeScript` |
| `path:<pattern>` | Restrict to files whose path matches the glob or substring | `config path:src/config` |
| `filename:<name>` | Match files by name (supports wildcards) | `SECRET filename:.env` |
| `extension:<ext>` | Match files by extension | `connect extension:ts` |
| `repo:<owner>/<repo>` | Restrict to a single repository (less useful here — use `--org`) | `connect repo:fulll/billing-api` |
| `NOT <term>` | Exclude a keyword | `connect NOT deprecated` |
| `"exact phrase"` | Exact multi-word match | `"feature flag"` |
| Qualifier | Description | Example |
| --------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| `language:<lang>` | Filter by programming language | `useFeatureFlag language:TypeScript` |
| `path:<directory>` | Restrict to files located in a directory (or any of its subdirectories) — **not** a glob/extension filter | `config path:src/config` |
| `filename:<name>` | Match files by name (supports wildcards) | `SECRET filename:.env` |
| `extension:<ext>` | Match files by extension | `connect extension:ts` |
| `repo:<owner>/<repo>` | Restrict to a single repository (less useful here — use `--org`) | `connect repo:fulll/service-b` |
| `NOT <term>` | Exclude a keyword | `connect NOT deprecated` |
| `"exact phrase"` | Exact multi-word match | `"feature flag"` |

::: tip
Qualifiers can be combined freely:
`"feature flag" language:TypeScript path:src/`
:::

::: warning `path:` does not support glob wildcards
`path:` matches a **directory location**, not a filename pattern — GitHub's code
search API silently ignores the `*` wildcard character rather than expanding it
as a glob, so a query like `path:*.tf` matches few or no files. To filter by
file type, use `language:<lang>` or `extension:<ext>` instead:

```bash
# Wrong — path:*.tf is silently ignored by the GitHub API, returns no results
github-code-search "ACME123456789 path:*.tf" --org fulll

# Right — filters by language or extension instead
github-code-search "ACME123456789 language:hcl" --org fulll
github-code-search "ACME123456789 extension:tf" --org fulll
```

`github-code-search` detects this pattern and prints a warning on stderr when a
`path:` qualifier contains a `*` character.
:::

## Practical examples

### Find all usages of a function
Expand Down Expand Up @@ -66,7 +85,7 @@ github-code-search "useFeatureFlag NOT filename:test NOT filename:spec" --org fu
Although `--org` already limits the search to your organisation, you can further narrow results to one or more specific repositories using `repo:` qualifiers in the query string:

```bash
github-code-search "useFeatureFlag repo:fulll/billing-api repo:fulll/auth-service" --org fulll
github-code-search "useFeatureFlag repo:fulll/service-b repo:fulll/service-a" --org fulll
```

`--org` is still required for the API call even when `repo:` qualifiers are present. The `org:<org>` qualifier is injected automatically alongside your query.
Expand Down
Loading
Loading