batless 0.2.2

A non-blocking, LLM-friendly code viewer inspired by bat
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
# 🦇 batless

<div align="center">

**The Ultimate Non-Blocking Code Viewer**

Built for automation, AI assistants, and modern CLI workflows

[Quick Start](#-quick-start) • [Features](#-features) • [Installation](#-installation-options) •
[Documentation](#-documentation) • [Examples](#-examples)

[![Crates.io](https://img.shields.io/crates/v/batless?logo=rust&logoColor=white)](https://crates.io/crates/batless)
[![Crates.io Downloads](https://img.shields.io/crates/d/batless?logo=rust&logoColor=white)](https://crates.io/crates/batless)
[![GitHub Downloads](https://img.shields.io/github/downloads/docdyhr/batless/total?logo=github&logoColor=white)](https://github.com/docdyhr/batless/releases)
[![License: MIT](https://img.shields.io/badge/License-MIT-green?logo=opensource&logoColor=white)](https://opensource.org/licenses/MIT)
[![GitHub Release](https://img.shields.io/github/v/release/docdyhr/batless?include_prereleases&logo=github&logoColor=white)](https://github.com/docdyhr/batless/releases)

[![CI/CD Pipeline](https://github.com/docdyhr/batless/workflows/CI%2FCD/badge.svg)](https://github.com/docdyhr/batless/actions)
[![Security Review](https://github.com/docdyhr/batless/workflows/Security%20Review/badge.svg)](https://github.com/docdyhr/batless/actions)
[![Codecov](https://codecov.io/gh/docdyhr/batless/branch/main/graph/badge.svg?logo=codecov&logoColor=white)](https://codecov.io/gh/docdyhr/batless)
[![Test Coverage](https://img.shields.io/badge/test%20coverage-90%25%2B-brightgreen?logo=jest&logoColor=white)](https://github.com/docdyhr/batless)

[![Rust](https://img.shields.io/badge/Rust-100%25-orange?logo=rust&logoColor=white)](https://github.com/docdyhr/batless)
[![Security Tests](https://img.shields.io/badge/security%20tests-passing-brightgreen?logo=shield&logoColor=white)](https://github.com/docdyhr/batless)
[![Performance](https://img.shields.io/badge/startup-<50ms-brightgreen?logo=speedtest&logoColor=white)](https://github.com/docdyhr/batless)
[![Binary Size](https://img.shields.io/badge/binary%20size-~2MB-blue?logo=filetype&logoColor=white)](https://github.com/docdyhr/batless)

</div>

## 🎯 Why batless?

**Transform code viewing** from blocking interactive pagers to predictable streaming output:

```text
❌ Before: bat file.rs → hangs in CI/CD, requires terminal, blocks automation
✅ After:  batless file.rs → streams immediately, works everywhere, never blocks
```

**Key Advantages:**

- 🚀 **Never Blocks**: Guaranteed non-blocking operation for CI/CD and automation
- 🤖 **AI-Optimized**: JSON output, summaries, and tokens for LLM processing
-**Blazing Fast**: <50ms startup, streaming architecture, ~2MB binary
- 🔧 **Automation-First**: Clean defaults, predictable behavior, perfect for scripts
- 📊 **Smart Output**: Multiple modes including summary extraction and token analysis

**batless** is a minimal, blazing-fast syntax viewer that **never blocks, never pages, never hangs**. While [`bat`](https://github.com/sharkdp/bat) is a feature-rich "cat with wings" for human users, `batless` is purpose-built for:

- 🤖 **AI code assistants** that need predictable, streaming output
- 🔄 **CI/CD pipelines** where interactive pagers would hang forever
- 📜 **Automation scripts** that require guaranteed non-blocking behavior
- 🚀 **Modern workflows** where JSON output and code summaries matter more than line numbers

**Core guarantee**: `batless` will NEVER wait for user input or block your pipeline.

## 🚀 Quick Start

Get up and running in **under 2 minutes**:

### Prerequisites

- **Rust Toolchain**: For building from source (or use pre-built binaries)
- **Terminal**: Any POSIX-compatible shell
- **Files to View**: Any text-based source code files

### 3-Step Setup

**1️⃣ Install batless (Choose One)**

```bash
# Option A: Pre-built binaries (fastest)
curl -L https://github.com/docdyhr/batless/releases/latest/download/batless-x86_64-unknown-linux-gnu.tar.gz | tar xz

# Option B: Via Cargo
cargo install batless

# Option C: Homebrew (macOS/Linux)
brew tap docdyhr/batless && brew install batless
```

**2️⃣ Test Your Installation**

```bash
# View a file with syntax highlighting
batless src/main.rs

# Test JSON output mode
batless --mode=json --max-lines=10 src/lib.rs
```

**3️⃣ Integrate with Your Workflow**

```bash
# CI/CD pipeline usage
batless --mode=summary --max-lines=50 failing-test.rs

# AI assistant context
batless --mode=json --include-tokens --summary src/main.rs
```

📺 **[Try the Demo]demo.sh** | 📖 **[Complete Setup Guide]#-installation-options**

## 🌟 What Makes batless Special

### 🏆 Feature Comparison

| Feature | `batless` | `bat` | `cat` |
|---------|-----------|-------|-------|
| **Never Blocks** |**Guaranteed** | ❌ Uses pager | ✅ Simple output |
| **Syntax Highlighting** | ✅ 100+ languages | ✅ Rich highlighting | ❌ None |
| **JSON Output** |**First-class** | ❌ Not supported | ❌ Not supported |
| **Summary Mode** |**AI-optimized** | ❌ Not supported | ❌ Not supported |
| **Memory Usage** |**Streaming** | ⚠️ Loads full file | ✅ Streaming |
| **Binary Size** |**~2MB** | ⚠️ ~10MB | ✅ System binary |
| **Startup Time** |**<50ms** | ⚠️ ~180ms |<10ms |

### 🚀 Core Capabilities

#### Non-Blocking Guarantees

- 🚫 **NEVER uses a pager** - no `less`, no `more`, no blocking
-**NEVER waits for input** - always streams output immediately
- 🔄 **NEVER hangs in pipes** - safe for `|`, `>`, and subprocess calls
- 📊 **ALWAYS returns quickly** - even on huge files (streaming architecture)

#### Syntax & Language Support

- 🎨 **Syntax highlighting** for 100+ languages via syntect
- 🔍 **Language auto-detection** with manual override support
- 🎭 **Theme support** - Multiple color schemes available
- 🌐 **Universal support** - Works with any text-based file format

#### Smart Output Modes

- 📊 **Multiple output modes**: plain, highlighted, JSON, summary
- 📏 **Smart limiting** by lines AND/OR bytes
- 💾 **Memory efficient** - true streaming, never loads full files
- 🎯 **Predictable behavior** - same output in terminal or pipe

#### Built for Automation

- 🤖 **AI-optimized JSON** output with metadata, tokens, and summaries
- 📋 **Summary mode** extracts functions, classes, imports only
- 🔤 **Token extraction** for LLM context processing
- 🚫 **Clean defaults** - no line numbers, headers, or decorations
- 📦 **Single ~2MB binary** with minimal dependencies
- 🚀 **Sub-50ms startup** with cached syntax definitions

## ⚡ Installation Options

### GitHub Releases (Recommended)

Download pre-compiled binaries for your platform:

```bash
# macOS/Linux - download and extract latest release
curl -L https://github.com/docdyhr/batless/releases/latest/download/batless-0.1.1-x86_64-apple-darwin.tar.gz | tar xz

# Or use wget
wget https://github.com/docdyhr/batless/releases/latest/download/batless-0.1.1-x86_64-unknown-linux-gnu.tar.gz
```

Available builds:

- **Linux**: `x86_64-unknown-linux-gnu`, `x86_64-unknown-linux-musl`, `aarch64-unknown-linux-gnu`
- **macOS**: `x86_64-apple-darwin` (Intel), `aarch64-apple-darwin` (Apple Silicon)
- **Windows**: `x86_64-pc-windows-msvc`

### Homebrew (macOS/Linux)

```bash
# Add the tap (one-time setup)
brew tap docdyhr/batless

# Install batless
brew install batless

# Or install directly without adding tap
brew install docdyhr/batless/batless
```

**Homebrew Tap Repository**: [docdyhr/homebrew-batless](https://github.com/docdyhr/homebrew-batless)

### From Crates.io

```bash
# Install the latest version:
cargo install batless
```

### Docker (Containerized Environments)

```bash
# Quick syntax highlighting in any environment
docker run --rm -v $(pwd):/workspace ghcr.io/docdyhr/batless:latest /workspace/src/main.rs

# JSON output for CI/CD pipelines
docker run --rm -v $(pwd):/workspace ghcr.io/docdyhr/batless:latest --mode=json /workspace/src/main.rs

# Summary mode for AI code analysis
docker run --rm -v $(pwd):/workspace ghcr.io/docdyhr/batless:latest --mode=summary /workspace/src/
```

### From Source

```bash
git clone https://github.com/docdyhr/batless.git
cd batless
cargo build --release
```

## 🍺 Homebrew Tap

The [docdyhr/homebrew-batless](https://github.com/docdyhr/homebrew-batless) tap provides the official Homebrew formula for `batless`.

### Features

- **Automatically updated** with every release
-**Comprehensive testing** included in formula
-**Cross-platform** support (macOS & Linux)
-**Zero maintenance** - formula stays in sync with releases

### Installation Commands

```bash
# Method 1: Add tap first (recommended)
brew tap docdyhr/batless
brew install batless

# Method 2: Direct install
brew install docdyhr/batless/batless

# Upgrade to latest version
brew upgrade batless
```

The formula automatically compiles from source using Rust, ensuring optimal performance for your system.

## 🎯 Real-World Use Cases

### 🤖 AI Assistant Integration

**Claude Code Assistant:**

```bash
# Get code structure for AI analysis
batless --mode=summary --max-lines=50 complex-file.py

# Full AI context with summary and tokens
batless --mode=json --summary --include-tokens --max-lines=100 src/main.rs

# List supported languages for analysis
batless --list-languages | grep -i python
```

**ChatGPT & GitHub Copilot:**

```bash
# Generate clean context without decorations
batless --color=never --max-lines=200 src/lib.rs

# Extract function signatures and imports only
batless --mode=summary src/main.rs

# Get JSON metadata for automated processing
batless --mode=json --max-bytes=5000 large-file.js
```

### 🔄 CI/CD Pipeline Integration

**GitHub Actions Example:**

```yaml
- name: Show failing test context
  run: |
    batless --mode=summary --max-lines=100 tests/failing_test.rs

- name: Extract code metrics
  run: |
    batless --mode=json src/main.rs | jq '.total_lines'
```

**Jenkins Pipeline:**

```groovy
stage('Code Analysis') {
    steps {
        sh 'batless --mode=json --summary src/ | jq ".summary_lines | length"'
    }
}
```

**GitLab CI:**

```yaml
code_review:
  script:
    - batless --color=never --max-lines=50 src/main.rs
    - batless --mode=summary --max-lines=100 tests/
```

### 🛠️ Development Workflows

**Code Review Automation:**

```bash
# Show changed files without paging
git diff --name-only | xargs batless --mode=summary

# Generate PR context for AI review
batless --mode=json --include-tokens changed-files.rs

# Quick file preview in terminal
batless --max-lines=30 --theme="InspiredGitHub" src/new-feature.rs
```

**Documentation Generation:**

```bash
# Extract code structure for docs
batless --mode=summary src/ > code-structure.md

# Generate API documentation context
batless --mode=json --summary src/api.rs | jq '.summary_lines[]'

# Create code snippets for tutorials
batless --max-lines=20 examples/hello-world.rs
```

### 📊 Performance Monitoring

**Build System Integration:**

```bash
# Show code during build failures (non-blocking)
batless --color=never --max-lines=30 failing-test.js

# Get code summary for automated analysis
batless --mode=summary --color=never failing-module.py

# Extract enhanced metadata for build systems
batless --mode=json src/main.rs | jq '{language, encoding, total_lines, truncated}'
```

**Large File Processing:**

```bash
# Process huge files without memory issues
batless --max-bytes=1048576 --mode=summary huge-log-file.txt

# Stream first 1000 lines of large dataset
batless --max-lines=1000 --mode=plain data/large-dataset.csv

# Extract key information from massive JSON
batless --max-bytes=500000 --mode=json config/large-config.json
```

## 📖 Usage

### Basic Usage

```bash
# View a file with syntax highlighting
batless src/main.rs

# Plain text output (no colors)
batless --mode=plain src/main.rs

# JSON output for parsing
batless --mode=json src/main.rs
```

### PAGER Compatibility

**🔧 Use as PAGER replacement** - Perfect for tools like GitHub CLI:

```bash
# GitHub CLI integration
PAGER="batless --plain" gh pr view 46

# General PAGER replacement
export PAGER="batless --plain"

# Pipeline input support
echo "Sample content" | batless --plain

# Compatible flags (ignored for compatibility)
batless --plain --unbuffered --number file.txt
```

**Key PAGER features:**

- `--plain` flag for plain text output (no colors/decorations)
- ✅ stdin support for pipeline input
- ✅ Compatible with existing PAGER workflows
- ✅ Gracefully ignores common PAGER flags (`--unbuffered`, `--number`)

### Limiting Output

```bash
# Limit to first 50 lines
batless --max-lines=50 large-file.py

# Limit to first 1KB
batless --max-bytes=1024 data.json

# Combine limits
batless --max-lines=100 --max-bytes=5000 file.txt
```

### Language and Syntax

```bash
# Auto-detect language (default)
batless script.py

# Force specific language
batless --language=python unknown-extension

# List supported languages
batless --language=help
```

### Color and Themes

```bash
# Control color output
batless --color=always file.rs    # Force colors
batless --color=never file.rs     # No colors
batless --color=auto file.rs      # Auto-detect terminal

# Choose syntax theme
batless --theme="Solarized (dark)" file.rs
batless --theme="InspiredGitHub" file.rs

# List all supported languages and themes
batless --list-languages
batless --list-themes

# Strip ANSI codes from output
batless --strip-ansi file.rs
```

### Enhanced JSON Mode Examples

```bash
# Get structured file info with enhanced metadata
batless --mode=json --max-lines=10 src/main.rs
```

Output:

```json
{
  "file": "src/main.rs",
  "language": "Rust",
  "lines": ["use std::io;", "// ..."],
  "total_lines": 10,
  "total_bytes": 245,
  "truncated": true,
  "truncated_by_lines": true,
  "truncated_by_bytes": false,
  "encoding": "UTF-8",
  "syntax_errors": [],
  "mode": "json"
}
```

### AI-Friendly Summary Mode

```bash
# Extract only important code structures (perfect for AI context)
batless --mode=summary src/main.rs

# Get function signatures, class definitions, imports only
batless --mode=summary --max-lines=50 complex-file.py
```

### Advanced JSON with Tokens and Summary

```bash
# Full AI analysis with tokens and code summary
batless --mode=json --include-tokens --summary src/main.rs
```

Enhanced output:

```json
{
  "file": "src/main.rs",
  "language": "Rust",
  "lines": ["use std::io;", "fn main() {", "..."],
  "summary_lines": ["use std::io;", "fn main() {", "pub struct Config {"],
  "tokens": ["use", "std", "io", "fn", "main", "pub", "struct", "Config"],
  "total_lines": 150,
  "total_bytes": 3420,
  "truncated": false,
  "encoding": "UTF-8",
  "mode": "json"
}
```

## 🐳 Docker Usage

### Container-Based Code Analysis

```bash
# Basic syntax highlighting
docker run --rm -v $(pwd):/workspace \
  ghcr.io/docdyhr/batless:latest /workspace/src/main.rs

# JSON output for CI/CD integration
docker run --rm -v $(pwd):/workspace \
  ghcr.io/docdyhr/batless:latest --mode=json /workspace/src/main.rs

# AI-friendly summary extraction
docker run --rm -v $(pwd):/workspace \
  ghcr.io/docdyhr/batless:latest --mode=summary /workspace/src/
```

### CI/CD Pipeline Integration

```yaml
# GitHub Actions example
- name: Analyze code structure
  run: |
    docker run --rm -v ${{ github.workspace }}:/workspace \
      ghcr.io/docdyhr/batless:latest \
      --mode=json --max-lines=100 /workspace/src/main.rs | \
      jq '.summary_lines | length'

# GitLab CI example
analyze_code:
  image: docker:latest
  script:
    - docker run --rm -v $PWD:/workspace
        ghcr.io/docdyhr/batless:latest
        --mode=summary /workspace/src/
```

### Kubernetes Jobs

```yaml
apiVersion: batch/v1
kind: Job
metadata:
  name: code-analysis
spec:
  template:
    spec:
      containers:
      - name: batless
        image: ghcr.io/docdyhr/batless:latest
        args: ["--mode=json", "/workspace/src/main.rs"]
        volumeMounts:
        - name: source-code
          mountPath: /workspace
      volumes:
      - name: source-code
        hostPath:
          path: /path/to/source
      restartPolicy: Never
```

## 🤖 AI Assistant Integration

### Claude Code Assistant

```bash
# Get code structure for AI analysis
batless --mode=summary --max-lines=50 complex-file.py

# Full AI context with summary and tokens
batless --mode=json --summary --include-tokens --max-lines=100 src/main.rs

# List supported languages for analysis
batless --list-languages | grep -i python
```

### CI/CD Pipelines

```bash
# Show code during build failures (non-blocking)
batless --color=never --max-lines=30 failing-test.js

# Get code summary for automated analysis
batless --mode=summary --color=never failing-module.py

# Extract enhanced metadata for build systems
batless --mode=json src/main.rs | jq '{language, encoding, total_lines, truncated}'
```

## 🎨 Available Themes

Popular themes include:

- `base16-ocean.dark` (default)
- `InspiredGitHub`
- `Solarized (dark)`
- `Solarized (light)`
- `Monokai`
- `1337`

View all available themes:

```bash
batless --list-themes
```

## 🗣️ Supported Languages

Support for 100+ languages including:

- Rust, Python, JavaScript, TypeScript
- C, C++, Java, Go, Swift
- HTML, CSS, JSON, YAML, TOML
- Shell, Bash, PowerShell
- And many more...

View all supported languages:

```bash
batless --list-languages
```

## ⚙️ Configuration

`batless` supports flexible configuration through files and command-line arguments, with a clear precedence hierarchy:

**Configuration Precedence** (highest to lowest):

1. Command-line arguments
2. Project-level config (`.batlessrc`, `batless.toml`)
3. User home config (`~/.batlessrc`, `~/.config/batless/config.toml`)
4. System defaults

### Configuration Files

#### TOML Format (Recommended)

Create `batless.toml` in your project root or `~/.config/batless/config.toml`:

```toml
# Maximum lines to display
max_lines = 15000

# Maximum bytes to process (optional)
max_bytes = 1048576  # 1MB

# Override language detection
language = "rust"

# Theme for syntax highlighting
theme = "monokai"

# Color output control
use_color = true

# Strip ANSI escape sequences
strip_ansi = false

# Include tokens in JSON output
include_tokens = false

# Enable summary mode by default
summary_mode = true
```

#### JSON Format (.batlessrc)

Create `.batlessrc` in your project root or home directory:

```json
{
  "max_lines": 8000,
  "theme": "github",
  "use_color": true,
  "summary_mode": false,
  "include_tokens": true
}
```

### Configuration Examples

#### Project-Specific Settings

For a Rust project, create `batless.toml`:

```toml
# Optimize for Rust development
max_lines = 20000
theme = "base16-ocean.dark"
language = "rust"
summary_mode = true
use_color = true
```

#### AI Assistant Profile

For AI code analysis, create `.batlessrc`:

```json
{
  "max_lines": 5000,
  "theme": "github",
  "use_color": false,
  "summary_mode": true,
  "include_tokens": false
}
```

#### CI/CD Pipeline Settings

For automation environments:

```toml
max_lines = 1000
use_color = false
strip_ansi = true
summary_mode = false
```

### Custom Config File

Use `--config` to specify a custom configuration file:

```bash
# Use specific config file
batless --config my-config.toml src/main.rs

# Override with command line args
batless --config team-settings.toml --max-lines 500 src/lib.rs
```

### Configuration Discovery

`batless` automatically searches for config files in this order:

1. **Project level**: `.batlessrc`, `batless.toml`
2. **User home**: `~/.batlessrc`, `~/.config/batless/config.toml`
3. **System level**: System config directories

### AI Tool Profiles

Instead of manual configuration, use built-in AI profiles:

```bash
# Claude-optimized (4K lines, summary mode)
batless --profile claude src/main.rs

# GitHub Copilot (2K lines, JSON + tokens)
batless --profile copilot src/main.rs

# ChatGPT-optimized (3K lines, JSON + tokens)
batless --profile chatgpt src/main.rs

# General AI assistant (5K lines, summary)
batless --profile assistant src/main.rs
```

### Validation and Help

`batless` validates all configuration and provides helpful error messages:

```bash
# Example validation error
$ batless --max-lines 0 src/main.rs
Error: max_lines must be greater than 0
Help: Try using --max-lines with a positive number (e.g., --max-lines 1000)
```

Common configuration patterns and their use cases are documented in the [project wiki](https://github.com/docdyhr/batless/wiki/Configuration-Examples).

## 🆚 Why batless instead of bat?

### When to use `batless`

- **CI/CD pipelines** - Guaranteed to never hang waiting for input
-**AI assistants** - Clean output with JSON mode and code summaries
-**Automation scripts** - Predictable, streaming behavior
-**Large file processing** - Memory-efficient streaming architecture
-**Headless environments** - No terminal detection or pager issues

### When to use `bat`

- **Interactive terminal use** - Rich features like paging and git integration
-**Human code review** - Line numbers, file headers, and decorations
-**Git workflows** - Shows inline diffs and modifications
-**Terminal multiplexing** - Full terminal UI features

### Feature Comparison

| Feature | `batless` | `bat` |
|---------|-----------|-------|
| **Core Philosophy** | Built for machines | Built for humans |
| **Blocking behavior** |**NEVER blocks** | ❌ Uses interactive pager |
| **Default output** | ✅ Clean, no decorations | ❌ Headers, grids, line numbers |
| **JSON output** | ✅ First-class with metadata | ❌ Not supported |
| **Summary mode** | ✅ Extract code structure | ❌ Not supported |
| **Token extraction** | ✅ For AI processing | ❌ Not supported |
| **Byte limiting** | ✅ Memory-safe streaming | ❌ Loads entire file |
| **Binary size** | ✅ ~2MB minimal | ❌ ~10MB with features |
| **Startup time** |<50ms cached | ⚠️ ~180ms full init |
| **Dependencies** | ✅ 9 crates | ❌ 20+ crates |
| **Git integration** | ❌ No (by design) | ✅ Full support |
| **Line numbers** | ❌ No (use `cat -n` if needed) | ✅ Configurable |
| **Interactive paging** | ❌ No (by design) | ✅ Smart pager integration |

## 🧪 Testing & Status

### Current Test Status ✅

- **Main Test Suite**: 100% passed
- **Integration Tests**: 100% passed
- **Property-Based Tests**: 100% passed
- **Security Audit**: Clean
- **CI/CD Pipeline**: Fully functional

### Test Your Installation

```bash
# Run the demo script
./demo.sh

# Test with a sample file
echo 'fn main() { println!("Hello, World!"); }' | batless --language=rust

# Verify JSON output
batless --mode=json src/main.rs | jq '.language'
```

## 🔒 Security Status

### Comprehensive Security Testing

Our security posture is continuously monitored through automated testing and vulnerability scanning:

| **Security Area** | **Status** | **Coverage** |
|------------------|------------|--------------|
| **Memory Safety** | ✅ Secure | Rust's memory safety guarantees |
| **Input Validation** | ✅ Secure | All inputs validated and sanitized |
| **Dependency Audit** | ✅ Secure | Regular `cargo audit` checks |
| **Binary Security** | ✅ Secure | Stripped, optimized releases |
| **Supply Chain** | ✅ Secure | Trusted dependencies only |

### Security Features

- **🛡️ Memory Safety**: Built with Rust for guaranteed memory safety
- **🔍 Input Validation**: All file paths and parameters validated
- **📊 Dependency Audit**: Automated vulnerability scanning
- **🚨 Safe Defaults**: No unsafe operations or external commands

### Security Testing Commands

```bash
# Security audit
cargo audit

# Dependency check
cargo deny check

# Format and lint checks
cargo fmt --all -- --check
cargo clippy -- -D warnings
```

## 🐛 Troubleshooting

### Quick Diagnostics

**Installation Issues**

```bash
# Verify Rust toolchain
rustc --version
cargo --version

# Check binary location
which batless
batless --version

# Test basic functionality
echo "test" | batless --mode=plain
```

**Performance Issues**

```bash
# Check syntax cache
ls ~/.cache/batless/ || ls ~/Library/Caches/batless/

# Benchmark performance
time batless --mode=summary large-file.rs

# Memory usage monitoring
/usr/bin/time -v batless large-file.rs
```

**Output Format Issues**

```bash
# Test color support
batless --color=always test-file.rs

# Verify JSON format
batless --mode=json test-file.rs | jq .

# Check theme availability
batless --list-themes
```

### Common Error Solutions

| Error | Cause | Solution |
|-------|-------|----------|
| `No such file or directory` | File path incorrect | Verify file path exists |
| `Permission denied` | File permissions | Check read permissions |
| `Language not found` | Unknown extension | Use `--language` flag |
| `JSON parse error` | Invalid JSON output | Check file encoding |
| `Binary not found` | Installation issue | Reinstall or check PATH |

### Getting Help

**Self-Diagnostics**

```bash
# Version and build info
batless --version

# List all supported languages
batless --list-languages

# List all themes
batless --list-themes

# Test configuration
batless --help
```

**Community Support**

- 🐛 [Report Issues]https://github.com/docdyhr/batless/issues
- 💬 [Discussions]https://github.com/docdyhr/batless/discussions
- 📚 [Documentation]https://github.com/docdyhr/batless/wiki
- 📧 [Contact]mailto:support@docdyhr.com

## 🛠️ Development

### Running Tests

```bash
# Run all tests
cargo test

# Run property-based tests
cargo test --test property_tests

# Run benchmarks
cargo bench

# Run security checks
./scripts/security-check.sh
```

### Building & Quality Checks

```bash
# Build release
cargo build --release

# Comprehensive linting
cargo clippy --all-targets --all-features -- -D warnings

# Code formatting
cargo fmt --all -- --check

# Security audit
cargo audit

# Generate coverage report
cargo install cargo-llvm-cov
cargo llvm-cov --html
```

### Security & Testing

This project maintains high security and quality standards:

- **90%+ test coverage** with unit, integration, and property-based tests
-**Daily security audits** with automated vulnerability scanning
-**Fuzz testing** for crash resistance and input validation
-**Memory safety** verification with Valgrind
-**Supply chain security** with OSSF Scorecard monitoring
-**Performance benchmarking** with regression detection

See [SECURITY_TESTING.md](SECURITY_TESTING.md) for detailed security measures.

## 📊 Performance

`batless` is designed for speed and low memory usage:

- **Streaming**: Never loads entire files into memory
- **Fast startup**: Cached syntax sets and optimized loading
- **Efficient highlighting**: Pre-loaded syntax and theme sets
- **Small binary**: ~2MB release build
- **Memory efficient**: Constant memory usage regardless of file size

Enhanced benchmarks on a 10MB Python file:

```
batless (optimized): 95ms (streaming + cached)
batless (summary): 45ms (structure only)
bat: 180ms (full load)
cat: 50ms (no highlighting)
```

## 🤝 Contributing

Contributions are welcome! Please:

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### Branch Protection & Contributing

This repository uses branch protection rules to ensure code quality and security:

- **Pull requests required** - No direct commits to `main`
- **CI/CD checks required** - All tests must pass
- **GPG signed commits recommended** - For authenticity verification

#### Quick Setup

```bash
# Setup branch protection (one-time)
gh auth login
./scripts/setup-branch-protection-gh.sh

# Verify configuration
./scripts/verify-protection-gh.sh
```

#### Development Workflow

```bash
# 1. Create feature branch
git checkout -b feature/my-feature

# 2. Make changes and commit
git add .
git commit -m "feat: description"

# 3. Push and create PR
git push origin feature/my-feature
gh pr create --title "feat: description"

# 4. Wait for CI, then merge
gh pr merge --squash
```

See [`docs/BRANCH_PROTECTION.md`](docs/BRANCH_PROTECTION.md) for detailed guidance.

### Release Automation

This project features fully automated releases and Homebrew tap updates:

- **Automated Releases**: Every git tag triggers cross-platform binary builds, GitHub releases, and crates.io publishing
- **Homebrew Integration**: The [homebrew-batless]https://github.com/docdyhr/homebrew-batless tap automatically updates with each release
- **Zero Maintenance**: Formula SHA256 hashes and versions are calculated and updated automatically

#### Release Process

```bash
# Create and push a new tag - everything else is automated
git tag v0.1.6
git push origin v0.1.6

# Automated workflows will:
# ✅ Build binaries for all platforms
# ✅ Create GitHub release with assets
# ✅ Publish to crates.io
# ✅ Update Homebrew tap with correct SHA256
# ✅ Users get latest version via all install methods
```

See [`docs/HOMEBREW_AUTOMATION.md`](docs/HOMEBREW_AUTOMATION.md) for technical details.

### Development Setup

```bash
git clone https://github.com/docdyhr/batless.git
cd batless
cargo test
cargo run -- --help
```

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- Inspired by [`sharkdp/bat`]https://github.com/sharkdp/bat
- Built with [`syntect`]https://github.com/trishume/syntect for syntax highlighting
- Designed for AI assistants like Claude and Gemini

## 📚 Documentation

### Getting Started

- **[Quick Start Guide]#-quick-start** - Get running in 2 minutes
- **[Installation Guide]#-installation-options** - All installation methods
- **[Usage Examples]#-real-world-use-cases** - Common workflows and patterns
- **[Troubleshooting]#-troubleshooting** - Common issues and solutions

### Advanced Usage

- **[Configuration Guide]CLAUDE.md** - All configuration options and profiles
- **[AI Integration Examples]#-ai-assistant-integration** - Claude, ChatGPT, Copilot
- **[CI/CD Integration]#-cicd-pipeline-integration** - GitHub Actions, Jenkins, GitLab
- **[Performance Tuning]#-performance** - Optimization tips and benchmarks

### Development

- **[Contributing Guide]CONTRIBUTING.md** - Development guidelines and setup
- **[Architecture Overview]DEVELOPMENT_GUIDE.md** - System design and structure
- **[Security Guidelines]SECURITY.md** - Security best practices
- **[Release Process]RELEASE.md** - How releases are managed

## 🚀 Next Steps

**Ready to transform your code viewing experience?**

1. **[Install batless]#-installation-options** - Choose your preferred method (2 minutes)
2. **🎯 [Try Real Examples]#-real-world-use-cases** - See what's possible with your workflow
3. **🤖 [Integrate with AI]#-ai-assistant-integration** - Enhance your AI assistant workflows
4. **💬 [Join Community]https://github.com/docdyhr/batless/discussions** - Get help and share ideas

---

## 🔗 Links & Resources

### Distribution Channels

- **Main Repository**: [github.com/docdyhr/batless]https://github.com/docdyhr/batless
- **Homebrew Tap**: [github.com/docdyhr/homebrew-batless]https://github.com/docdyhr/homebrew-batless
- **Crates.io Package**: [crates.io/crates/batless]https://crates.io/crates/batless
- **Documentation**: [docs.rs/batless]https://docs.rs/batless

### Community & Support

- **Issues & Bug Reports**: [github.com/docdyhr/batless/issues]https://github.com/docdyhr/batless/issues
- **Feature Discussions**: [github.com/docdyhr/batless/discussions]https://github.com/docdyhr/batless/discussions
- **Security Reports**: [security@docdyhr.com]mailto:security@docdyhr.com
- **General Support**: [support@docdyhr.com]mailto:support@docdyhr.com

---

## 🙏 Acknowledgments

Special thanks to:

- **[sharkdp/bat]https://github.com/sharkdp/bat** - Inspiration for syntax highlighting excellence
- **[syntect]https://github.com/trishume/syntect** - Powerful syntax highlighting engine
- **Rust Community** - For building amazing tools and ecosystem
- **AI Assistant Communities** - For driving the need for automation-friendly tools

---

<div align="center">

**⭐ Found this helpful? [Give us a star on GitHub!](https://github.com/docdyhr/batless) ⭐**

**Made with ❤️ for AI assistants and modern CLI workflows**

</div>