Skip to content

Commit 497d702

Browse files
committed
Update README.md with new --output feature
1 parent 551a149 commit 497d702

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

README.md

+38-30
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This is a TypeScript port of the original `files-to-prompt` tool written in Pyth
1515

1616
Additional features not found the original version:
1717
- reading and parsing file paths received via `stdin` (e.g. via pipe from `grep` or `ripgrep`)
18+
- redirect output to a file with `--output <file>` or `-o <file>`
1819

1920
[^1]: The script needs a Typescript engine to run, of course.
2021

@@ -25,13 +26,13 @@ Additional features not found the original version:
2526
2. Download the script
2627
- Install via jsr.io
2728
```shell
28-
curl https://jsr.io/@fry69/files-to-prompt-ts/0.2.1/files-to-prompt.ts > ftp.ts
29+
curl https://jsr.io/@fry69/files-to-prompt-ts/0.3.0/files-to-prompt.ts > ftp.ts
2930
```
3031

3132
- Install via GitHub
3233

3334
```shell
34-
curl https://raw.githubusercontent.com/fry69/files-to-prompt-ts/v0.2.1/files-to-prompt.ts > ftp.ts
35+
curl https://raw.githubusercontent.com/fry69/files-to-prompt-ts/v0.3.0/files-to-prompt.ts > ftp.ts
3536
```
3637

3738
3. Make the script executable with `chmod +x ftp.ts`
@@ -49,9 +50,11 @@ Replace `<paths...>` with one or more paths to files or directories you want to
4950
5051
Available options:
5152
53+
- `--version`: Version of this script
5254
- `--include-hidden`: Include files and folders starting with `.` (default: `false`)
5355
- `--ignore-gitignore`: Ignore `.gitignore` files and include all files (default: `false`)
5456
- `-i, --ignore <pattern>`: Specify one or more patterns to ignore (can be used multiple times)
57+
- `-o, --output <file>`: Redirect output to `file` (**Note:** `file` will get silently overwritten)
5558
5659
Example usage:
5760
@@ -83,51 +86,56 @@ This tool includes a set of tests to ensure it works as expected. You can run th
8386
bun test --coverage
8487
```
8588
86-
Recent test status (v0.2.1):
89+
Recent test status (v0.3.0):
8790
8891
```
8992
bun test v1.1.4 (fbe2fe0c)
9093
9194
files-to-prompt.test.ts:
92-
✓ files-to-prompt.ts > should include single file passed on the command line [11.59ms]
93-
✓ files-to-prompt.ts > should include multiple files passed on the command line [6.86ms]
94-
✓ files-to-prompt.ts > should include files in directories passed on the command line [7.73ms]
95-
✓ files-to-prompt.ts > should include files a few levels deep in a directory structure [6.64ms]
95+
✓ files-to-prompt.ts > should include single file passed on the command line [11.52ms]
96+
✓ files-to-prompt.ts > should include multiple files passed on the command line [6.67ms]
97+
✓ files-to-prompt.ts > should include files in directories passed on the command line [7.52ms]
98+
✓ files-to-prompt.ts > should include files a few levels deep in a directory structure [6.65ms]
9699
✓ files-to-prompt.ts > should exclude files matching patterns passed via --ignore [6.61ms]
97-
✓ files-to-prompt.ts > should exclude files matching patterns passed via multiple --ignore [6.47ms]
98-
✓ files-to-prompt.ts > should fail when --ignore gets passed without an argument [5.89ms]
99-
✓ files-to-prompt.ts > should exclude files matching patterns in .gitignore [6.75ms]
100-
✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore [8.17ms]
101-
✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore in different directories [6.77ms]
102-
✓ files-to-prompt.ts > should include hidden files and directories when --include-hidden is passed [6.85ms]
103-
✓ files-to-prompt.ts > should ignore .gitignore files when --ignore-gitignore is passed [7.62ms]
104-
✓ files-to-prompt.ts > should skip binary files [6.88ms]
105-
✓ files-to-prompt.ts > should fail silently if isBinaryFile() gets called with invalid path [1.14ms]
106-
✓ files-to-prompt.ts > should skip FIFOs [20.92ms]
107-
✓ files-to-prompt.ts > should fail with error message if path does not exist [6.70ms]
108-
✓ files-to-prompt.ts > should parse file paths with parseFilePathsFromStdin() correctly [0.32ms]
100+
✓ files-to-prompt.ts > should exclude files matching patterns passed via multiple --ignore [6.57ms]
101+
✓ files-to-prompt.ts > should fail when --ignore gets passed without an argument [6.99ms]
102+
✓ files-to-prompt.ts > should exclude files matching patterns in .gitignore [6.82ms]
103+
✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore [7.99ms]
104+
✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore in different directories [6.71ms]
105+
✓ files-to-prompt.ts > should include hidden files and directories when --include-hidden is passed [8.19ms]
106+
✓ files-to-prompt.ts > should ignore .gitignore files when --ignore-gitignore is passed [6.46ms]
107+
✓ files-to-prompt.ts > should skip binary files [6.71ms]
108+
✓ files-to-prompt.ts > should fail silently if isBinaryFile() gets called with invalid path [1.18ms]
109+
✓ files-to-prompt.ts > should skip FIFOs [15.07ms]
110+
✓ files-to-prompt.ts > should fail with error message if path does not exist [6.76ms]
111+
✓ files-to-prompt.ts > should parse file paths with parseFilePathsFromStdin() correctly [0.27ms]
109112
✓ files-to-prompt.ts > should de-duplicate file paths with parseFilePathsFromStdin() [0.06ms]
110-
✓ files-to-prompt.ts > should parse file paths with one file path per line [0.07ms]
113+
✓ files-to-prompt.ts > should parse file paths with one file path per line [0.06ms]
111114
✓ files-to-prompt.ts > should handle mixed input formats [0.03ms]
112115
✓ files-to-prompt.ts > should handle empty lines in stdin data [0.03ms]
113-
✓ files-to-prompt.ts > should handle binary data in stdin [0.09ms]
116+
✓ files-to-prompt.ts > should handle binary data in stdin [0.08ms]
114117
✓ files-to-prompt.ts > should handle common text/code files in stdin [0.04ms]
115-
✓ files-to-prompt.ts > should handle long file paths in stdin [0.26ms]
116-
✓ files-to-prompt.ts > should ignore file paths with the null character [0.04ms]
117-
✓ files-to-prompt.ts > should ignore file paths with control characters [0.03ms]
118+
✓ files-to-prompt.ts > should handle long file paths in stdin [0.25ms]
119+
✓ files-to-prompt.ts > should ignore file paths with the null character [0.03ms]
120+
✓ files-to-prompt.ts > should ignore file paths with control characters [0.34ms]
118121
✓ files-to-prompt.ts > should output version string when --version is passed [0.10ms]
119-
✓ files-to-prompt.ts > should output error for unsupported options [0.06ms]
122+
✓ files-to-prompt.ts > should output error for unsupported options [0.09ms]
123+
✓ files-to-prompt.ts > should output to a file when --output is passed [6.80ms]
124+
✓ files-to-prompt.ts > should output to a file when -o is passed [7.74ms]
125+
✓ files-to-prompt.ts > should output error if --output is passed without a file path [5.84ms]
126+
✓ files-to-prompt.ts > should output error if -o is passed without a file path [7.02ms]
127+
✓ files-to-prompt.ts > should output error if output file cannot be written [6.02ms]
120128
--------------------|---------|---------|-------------------
121129
File | % Funcs | % Lines | Uncovered Line #s
122130
--------------------|---------|---------|-------------------
123-
All files | 88.00 | 88.38 |
124-
files-to-prompt.ts | 88.00 | 88.38 | 30,41,64,102,229-240,349-351,369-372
131+
All files | 88.89 | 87.98 |
132+
files-to-prompt.ts | 88.89 | 87.98 | 46,59,74,85-88,114,152,279-290,417-419,437-440
125133
--------------------|---------|---------|-------------------
126134
127-
28 pass
135+
33 pass
128136
0 fail
129-
59 expect() calls
130-
Ran 28 tests across 1 files. [165.00ms]
137+
73 expect() calls
138+
Ran 33 tests across 1 files. [195.00ms]
131139
```
132140
133141
## Compatibility

0 commit comments

Comments
 (0)