Skip to content

Commit

Permalink
Update README.md with new --output feature
Browse files Browse the repository at this point in the history
  • Loading branch information
fry69 committed Apr 18, 2024
1 parent 551a149 commit 497d702
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This is a TypeScript port of the original `files-to-prompt` tool written in Pyth

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

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

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

- Install via GitHub

```shell
curl https://raw.githubusercontent.com/fry69/files-to-prompt-ts/v0.2.1/files-to-prompt.ts > ftp.ts
curl https://raw.githubusercontent.com/fry69/files-to-prompt-ts/v0.3.0/files-to-prompt.ts > ftp.ts
```

3. Make the script executable with `chmod +x ftp.ts`
Expand All @@ -49,9 +50,11 @@ Replace `<paths...>` with one or more paths to files or directories you want to
Available options:
- `--version`: Version of this script
- `--include-hidden`: Include files and folders starting with `.` (default: `false`)
- `--ignore-gitignore`: Ignore `.gitignore` files and include all files (default: `false`)
- `-i, --ignore <pattern>`: Specify one or more patterns to ignore (can be used multiple times)
- `-o, --output <file>`: Redirect output to `file` (**Note:** `file` will get silently overwritten)
Example usage:
Expand Down Expand Up @@ -83,51 +86,56 @@ This tool includes a set of tests to ensure it works as expected. You can run th
bun test --coverage
```
Recent test status (v0.2.1):
Recent test status (v0.3.0):
```
bun test v1.1.4 (fbe2fe0c)
files-to-prompt.test.ts:
✓ files-to-prompt.ts > should include single file passed on the command line [11.59ms]
✓ files-to-prompt.ts > should include multiple files passed on the command line [6.86ms]
✓ files-to-prompt.ts > should include files in directories passed on the command line [7.73ms]
✓ files-to-prompt.ts > should include files a few levels deep in a directory structure [6.64ms]
✓ files-to-prompt.ts > should include single file passed on the command line [11.52ms]
✓ files-to-prompt.ts > should include multiple files passed on the command line [6.67ms]
✓ files-to-prompt.ts > should include files in directories passed on the command line [7.52ms]
✓ files-to-prompt.ts > should include files a few levels deep in a directory structure [6.65ms]
✓ files-to-prompt.ts > should exclude files matching patterns passed via --ignore [6.61ms]
✓ files-to-prompt.ts > should exclude files matching patterns passed via multiple --ignore [6.47ms]
✓ files-to-prompt.ts > should fail when --ignore gets passed without an argument [5.89ms]
✓ files-to-prompt.ts > should exclude files matching patterns in .gitignore [6.75ms]
✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore [8.17ms]
✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore in different directories [6.77ms]
✓ files-to-prompt.ts > should include hidden files and directories when --include-hidden is passed [6.85ms]
✓ files-to-prompt.ts > should ignore .gitignore files when --ignore-gitignore is passed [7.62ms]
✓ files-to-prompt.ts > should skip binary files [6.88ms]
✓ files-to-prompt.ts > should fail silently if isBinaryFile() gets called with invalid path [1.14ms]
✓ files-to-prompt.ts > should skip FIFOs [20.92ms]
✓ files-to-prompt.ts > should fail with error message if path does not exist [6.70ms]
✓ files-to-prompt.ts > should parse file paths with parseFilePathsFromStdin() correctly [0.32ms]
✓ files-to-prompt.ts > should exclude files matching patterns passed via multiple --ignore [6.57ms]
✓ files-to-prompt.ts > should fail when --ignore gets passed without an argument [6.99ms]
✓ files-to-prompt.ts > should exclude files matching patterns in .gitignore [6.82ms]
✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore [7.99ms]
✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore in different directories [6.71ms]
✓ files-to-prompt.ts > should include hidden files and directories when --include-hidden is passed [8.19ms]
✓ files-to-prompt.ts > should ignore .gitignore files when --ignore-gitignore is passed [6.46ms]
✓ files-to-prompt.ts > should skip binary files [6.71ms]
✓ files-to-prompt.ts > should fail silently if isBinaryFile() gets called with invalid path [1.18ms]
✓ files-to-prompt.ts > should skip FIFOs [15.07ms]
✓ files-to-prompt.ts > should fail with error message if path does not exist [6.76ms]
✓ files-to-prompt.ts > should parse file paths with parseFilePathsFromStdin() correctly [0.27ms]
✓ files-to-prompt.ts > should de-duplicate file paths with parseFilePathsFromStdin() [0.06ms]
✓ files-to-prompt.ts > should parse file paths with one file path per line [0.07ms]
✓ files-to-prompt.ts > should parse file paths with one file path per line [0.06ms]
✓ files-to-prompt.ts > should handle mixed input formats [0.03ms]
✓ files-to-prompt.ts > should handle empty lines in stdin data [0.03ms]
✓ files-to-prompt.ts > should handle binary data in stdin [0.09ms]
✓ files-to-prompt.ts > should handle binary data in stdin [0.08ms]
✓ files-to-prompt.ts > should handle common text/code files in stdin [0.04ms]
✓ files-to-prompt.ts > should handle long file paths in stdin [0.26ms]
✓ files-to-prompt.ts > should ignore file paths with the null character [0.04ms]
✓ files-to-prompt.ts > should ignore file paths with control characters [0.03ms]
✓ files-to-prompt.ts > should handle long file paths in stdin [0.25ms]
✓ files-to-prompt.ts > should ignore file paths with the null character [0.03ms]
✓ files-to-prompt.ts > should ignore file paths with control characters [0.34ms]
✓ files-to-prompt.ts > should output version string when --version is passed [0.10ms]
✓ files-to-prompt.ts > should output error for unsupported options [0.06ms]
✓ files-to-prompt.ts > should output error for unsupported options [0.09ms]
✓ files-to-prompt.ts > should output to a file when --output is passed [6.80ms]
✓ files-to-prompt.ts > should output to a file when -o is passed [7.74ms]
✓ files-to-prompt.ts > should output error if --output is passed without a file path [5.84ms]
✓ files-to-prompt.ts > should output error if -o is passed without a file path [7.02ms]
✓ files-to-prompt.ts > should output error if output file cannot be written [6.02ms]
--------------------|---------|---------|-------------------
File | % Funcs | % Lines | Uncovered Line #s
--------------------|---------|---------|-------------------
All files | 88.00 | 88.38 |
files-to-prompt.ts | 88.00 | 88.38 | 30,41,64,102,229-240,349-351,369-372
All files | 88.89 | 87.98 |
files-to-prompt.ts | 88.89 | 87.98 | 46,59,74,85-88,114,152,279-290,417-419,437-440
--------------------|---------|---------|-------------------
28 pass
33 pass
0 fail
59 expect() calls
Ran 28 tests across 1 files. [165.00ms]
73 expect() calls
Ran 33 tests across 1 files. [195.00ms]
```
## Compatibility
Expand Down

0 comments on commit 497d702

Please # to comment.