An open API service indexing awesome lists of open source software.

https://github.com/gorango/yank

A fast, simple CLI to grab, format, and copy source code.
https://github.com/gorango/yank

Last synced: 5 months ago
JSON representation

A fast, simple CLI to grab, format, and copy source code.

Awesome Lists containing this project

README

          

# `yank`

A fast, simple CLI to grab, format, and copy source code.

## Installation

```sh
npm install -g yank-cli
```

## Usage

#### Basic Usage

You can pass file and directory paths directly to `yank`. By default, it prints the formatted result to `stdout`, which is perfect for piping.

```sh
# Yank a specific directory to your clipboard
yank src --clip

# View multiple files and directories in a pager
yank config *.json | less
```

If you don't provide any paths, `yank` will grab all files in the current project (respecting `.gitignore`).

```sh
# Yank the entire project to stdout
yank
```

## Options

| Flag | Alias | Description | Default |
| :--- | :--- | :--- | :--- |
| `--clip` | `-c` | Send output to the system clipboard instead of `stdout`. | `false` |
| `--include` | `-i` | Glob patterns for files to include. **Ignored if paths are provided directly.** | `**/*` |
| `--exclude` | `-x` | Glob patterns to exclude. Appended to built-in defaults. | `[]` |
| `--name-template` | `-H` | Template for the file header. | `--- {filePath} ---` |
| `--code-template` | `-B` | Template for the code block. | ` ```{language}\n{content}\n``` ` |
| `--stats` | `-s` | Print summary statistics to `stderr`. | `false` |
| `--tokens` | `-t` | Print number of tokens in `stats`. | `false` |
| `--config` | `-C` | Path to a custom configuration file. | |
| `--debug` | | Enable verbose debug logging. | `false` |
| `--help` | `-h` | Show the help message. | |
| `--version` | `-v` | Show the version number. | |

## Config File

For project-specific defaults, create a configuration file. `yank` will automatically find and use it.

**Supported files:** `yank.toml`, `yank.yaml`, `yank.json`, `yank.config.js`, or a `yank` property in `package.json`.

#### Example `yank.toml`

````toml
# Always send output to clipboard for this project
clip = true

# Always show stats
stats = true

# Project-specific files to grab
include = [
"src/**/*.ts",
"README.md",
"package.json"
]

# Add extra patterns to the default exclude list
exclude = [
"**/*.spec.ts",
"**/*.test.ts"
]

# Customize formatting for this project
fileTemplate = "## {filePath}"
codeTemplate = """
```
{content}
```
"""
````