Skip to content

Commit 1f9a063

Browse files
committed
feat: copy mode
1 parent cfeece0 commit 1f9a063

File tree

4 files changed

+438
-52
lines changed

4 files changed

+438
-52
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Count LOC (lines of code) & TOK (LLM tokens), fast.
99
- Gitignore-aware scan (respects `.gitignore`, global gitignore, and git excludes)
1010
- Tiktoken encodings: `o200k_base` (default), `cl100k_base`, `p50k_base`, `p50k_edit`, `r50k_base`
1111
- By-language summary table, JSON report, or file tree view
12+
- Copy mode to concatenate filtered files into a clipboard-ready payload
1213
- Extension filter via `--ext rs,py,ts` (case-insensitive, no leading dots)
1314
- Optional inclusion of hidden files via `--hidden`
1415
- Fast parallel scanning (Rayon) with a live progress indicator (stderr)
@@ -62,6 +63,13 @@ loctok --hidden
6263

6364
# Progress prints to stderr; to silence in scripts, redirect:
6465
loctok --format json 2>/dev/null
66+
67+
# Concatenate filtered files and copy to clipboard
68+
loctok copy # from current directory
69+
loctok copy path/to/dir # from a given path
70+
71+
# Copy with filters and also print the content
72+
loctok --ext rs,md --hidden copy --show
6573
```
6674

6775
Run `loctok --help` to see all options.
@@ -158,11 +166,50 @@ Name LOC TOK
158166
}
159167
```
160168

169+
## Copy Mode
170+
171+
Use copy to bundle filtered files into a single, structured payload that is copied to your clipboard. Optionally print it with `--show`.
172+
173+
```
174+
loctok copy [PATH] [--show] [--ext rs,md] [--hidden]
175+
```
176+
177+
What it does:
178+
179+
- Renders a tree of the included files
180+
- Appends each file as a section with a header and numbered lines
181+
- Copies the entire payload to your system clipboard
182+
- Prints a summary like: `Copied 123 lines (22,333 tokens)`
183+
184+
Snippet of the format:
185+
186+
```
187+
├── src
188+
│ ├── lib.rs
189+
│ └── main.rs
190+
└── README.md
191+
192+
/src/lib.rs:
193+
--------------------------------------------------------------------------------
194+
1 | use anyhow::{Context, Result};
195+
2 | // ...
196+
197+
198+
/README.md:
199+
--------------------------------------------------------------------------------
200+
1 | # loctok
201+
2 | Count LOC and tokens
202+
```
203+
161204
## Behavior and Notes
162205

163206
- Respects `.gitignore`, global gitignore, and git excludes; also adds `.gitignore` as a custom ignore file in non-git contexts.
164207
- Only UTF‑8 text files are counted; non‑UTF‑8 files are skipped silently.
165208
- Language grouping is inferred from file extensions.
209+
- Copy mode requires a platform clipboard tool:
210+
- macOS: `pbcopy`
211+
- Windows: `clip`
212+
- Linux: `xclip` or `xsel`
166213

167214
## License
168215

npm/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ loctok --format json 2>/dev/null
5656

5757
# See all options
5858
loctok --help
59+
60+
# Concatenate filtered files and copy to clipboard
61+
loctok copy # from current directory
62+
loctok copy path/to/dir # from a given path
63+
64+
# Copy with filters and also print the content
65+
loctok --ext rs,md --hidden copy --show
5966
```
6067

6168
Supported encodings: `o200k_base` (default), `cl100k_base`, `p50k_base`, `p50k_edit`, `r50k_base`.
@@ -118,6 +125,32 @@ Notes:
118125

119126
- Progress updates print to stderr; they are in-place on TTYs and line-based otherwise.
120127
- Token counts use the chosen encoding; `token_number` and `models` are informative mapping hints.
128+
- Copy mode requires a platform clipboard tool:
129+
- macOS: `pbcopy`
130+
- Windows: `clip`
131+
- Linux: `xclip` or `xsel`
132+
133+
## Copy Mode
134+
135+
Use copy to bundle filtered files into a single, structured payload that is copied to your clipboard. Optionally print it with `--show`.
136+
137+
```
138+
loctok copy [PATH] [--show] [--ext rs,md] [--hidden]
139+
```
140+
141+
Format snippet:
142+
143+
```
144+
├── src
145+
│ ├── lib.rs
146+
│ └── main.rs
147+
└── README.md
148+
149+
/src/lib.rs:
150+
--------------------------------------------------------------------------------
151+
1 | use anyhow::{Context, Result};
152+
2 | // ...
153+
```
121154

122155
## Supported Platforms
123156

0 commit comments

Comments
 (0)