gosh-dl-cli 0.1.2

Command-line interface for the gosh-dl download engine
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
# gosh

[![Crates.io](https://img.shields.io/crates/v/gosh-dl-cli.svg)](https://crates.io/crates/gosh-dl-cli)
[![Documentation](https://docs.rs/gosh-dl-cli/badge.svg)](https://docs.rs/gosh-dl-cli)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![CI](https://github.com/goshitsarch-eng/gosh-dl-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/goshitsarch-eng/gosh-dl-cli/actions/workflows/ci.yml)

A fast, modern download manager CLI with HTTP/HTTPS multi-connection acceleration and full BitTorrent protocol support. Powered by [gosh-dl](https://github.com/goshitsarch-eng/gosh-dl).

## Features

- **HTTP/HTTPS Downloads**: Multi-connection segmented downloads (up to 16 parallel connections), automatic resume, checksum verification
- **BitTorrent**: Full protocol support with DHT, PEX, magnet links, encryption, and WebSeeds
- **Three Usage Modes**: Interactive TUI, direct aria2-style CLI, and scriptable commands
- **Cross-Platform**: Linux, macOS, and Windows support

## Installation

### From Source

```bash
git clone https://github.com/goshitsarch-eng/gosh-dl-cli
cd gosh-dl-cli
cargo build --release
sudo cp target/release/gosh /usr/local/bin/
```

### From Crates.io

```bash
cargo install gosh-dl-cli
```

### Pre-built Binaries

Download from [GitHub Releases](https://github.com/goshitsarch-eng/gosh-dl-cli/releases).

**Linux builds:** Statically linked with musl for maximum portability across all distributions (including Alpine).

## Usage Modes

gosh supports three distinct usage patterns:

### 1. Interactive TUI Mode

Launch without arguments to enter the full-screen terminal UI:

```bash
gosh
```

**TUI Keyboard Shortcuts:**

| Key | Action |
|-----|--------|
| `a` | Add new download |
| `p` | Pause selected |
| `r` | Resume selected |
| `c` | Cancel selected |
| `d` | Cancel and delete files |
| `1` | View all downloads |
| `2` | View active only |
| `3` | View completed only |
| `j`/`k` or arrows | Navigate |
| `?` | Show help |
| `q` or Ctrl+C | Quit |

### 2. Direct Download Mode (aria2-style)

Pass URLs directly to download immediately with progress bars:

```bash
# Single download
gosh https://example.com/file.zip

# Multiple parallel downloads
gosh https://example.com/file1.zip https://example.com/file2.zip

# With options
gosh -d /downloads -x 8 --max-speed 5M https://example.com/large-file.iso

# Torrent/Magnet
gosh magnet:?xt=urn:btih:...
gosh /path/to/file.torrent
```

### 3. Command Mode

Use subcommands for scriptable operations:

```bash
gosh add https://example.com/file.zip
gosh list
gosh status abc123
gosh pause abc123
gosh resume abc123
```

## Direct Download Options

When using direct download mode (`gosh URL`), the following options are available:

| Option | Description |
|--------|-------------|
| `-d, --dir <PATH>` | Output directory |
| `-o, --out <NAME>` | Output filename (single download only) |
| `-H, --header <HEADER>` | Custom header (format: "Name: Value") |
| `--user-agent <UA>` | User agent string |
| `--referer <URL>` | Referer URL |
| `--cookie <COOKIE>` | Cookie (format: "name=value") |
| `--checksum <HASH>` | Expected checksum (format: "md5:xxx" or "sha256:xxx") |
| `-x, --max-connections <N>` | Max connections per download |
| `--max-speed <SPEED>` | Max download speed (supports K/M/G suffixes) |
| `--sequential` | Sequential download mode (for torrents) |
| `--select-files <INDICES>` | Select specific files (comma-separated indices) |
| `--seed-ratio <RATIO>` | Seed ratio limit for torrents |

**Examples:**

```bash
# Download with custom headers and user agent
gosh -H "Authorization: Bearer token" --user-agent "MyApp/1.0" https://api.example.com/file

# Download with checksum verification
gosh --checksum sha256:abc123... https://example.com/important-file.iso

# Limit download speed to 5 MB/s with 8 connections
gosh -x 8 --max-speed 5M https://example.com/large-file.zip

# Download specific files from a torrent
gosh --select-files 0,2,5 /path/to/multi-file.torrent

# Sequential download for streaming
gosh --sequential magnet:?xt=urn:btih:...
```

## Commands Reference

### `gosh add`

Add a new download to the queue.

```bash
gosh add [OPTIONS] <URL>...

Options:
  -d, --dir <PATH>            Output directory
  -o, --out <NAME>            Output filename (single download only)
  -p, --priority <PRIORITY>   Priority [low, normal, high, critical]
  -w, --wait                  Wait for download to complete (show progress)
  -i, --input-file <FILE>     Read URLs from file (one per line)
  -H, --header <HEADER>       Custom header
      --user-agent <UA>       User agent string
      --referer <URL>         Referer URL
      --cookie <COOKIE>       Cookie
      --checksum <HASH>       Expected checksum
  -x, --max-connections <N>   Max connections
      --max-speed <SPEED>     Max download speed
      --sequential            Sequential mode (torrents)
      --select-files <IDX>    Select files (torrents)
      --seed-ratio <RATIO>    Seed ratio (torrents)
```

### `gosh list`

List all downloads.

```bash
gosh list [OPTIONS]

Options:
  -s, --state <STATE>   Filter by state [active, waiting, paused, completed, error]
      --ids-only        Show only download IDs
```

### `gosh status`

Show detailed status of a download.

```bash
gosh status [OPTIONS] <ID>

Options:
      --peers   Show peer information (torrents)
      --files   Show file list (torrents)
```

### `gosh pause`

Pause one or more downloads.

```bash
gosh pause <ID>...
gosh pause all    # Pause all active downloads
```

### `gosh resume`

Resume paused downloads.

```bash
gosh resume <ID>...
gosh resume all   # Resume all paused downloads
```

### `gosh cancel`

Cancel and optionally delete downloads.

```bash
gosh cancel [OPTIONS] <ID>...

Options:
      --delete   Also delete downloaded files
  -y, --yes      Skip confirmation prompt
```

### `gosh priority`

Set download priority.

```bash
gosh priority <ID> <PRIORITY>

Priorities: low, normal, high, critical
```

### `gosh stats`

Show global download/upload statistics.

```bash
gosh stats
```

Output:
```
Global Statistics
=================

Downloads:
  Active:   2
  Waiting:  5
  Stopped:  10
  Total:    17

Speed:
  Download: 5.2 MB/s
  Upload:   1.1 MB/s
```

### `gosh info`

Parse and display torrent file information.

```bash
gosh info <TORRENT_FILE>
```

### `gosh config`

Manage configuration.

```bash
gosh config show              # Show current config
gosh config path              # Show config file path
gosh config get <KEY>         # Get a config value
gosh config set <KEY> <VALUE> # Set a config value
```

## Global Options

These options can be used with any command:

| Option | Description |
|--------|-------------|
| `-c, --config <PATH>` | Config file path |
| `-v, --verbose` | Increase verbosity (-v, -vv, -vvv) |
| `-q, --quiet` | Suppress output except errors |
| `--output <FORMAT>` | Output format [table, json, json-pretty] |

## Configuration

Configuration file location: `~/.config/gosh/config.toml`

```toml
[general]
download_dir = "~/Downloads"
log_level = "warn"

[engine]
max_concurrent_downloads = 5
max_connections_per_download = 16
global_download_limit = 0      # 0 = unlimited
global_upload_limit = 0

# BitTorrent settings
enable_dht = true
enable_pex = true
enable_lpd = true
max_peers = 55
seed_ratio = 1.0

# HTTP settings
user_agent = "gosh/0.1"
connect_timeout = 30
read_timeout = 60

[tui]
refresh_rate_ms = 250
theme = "dark"                 # or "light"
show_speed_graph = true
```

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success (all downloads completed) |
| 1 | Partial failure (some downloads failed) |
| 2 | Total failure (all downloads failed) |
| 130 | Interrupted (Ctrl+C) |

## Comparison with aria2

gosh provides aria2-style command-line usage while offering a native Rust implementation:

| Feature | aria2c | gosh |
|---------|--------|------|
| Direct download | `aria2c URL` | `gosh URL` |
| Output directory | `-d /path` | `-d /path` |
| Max connections | `-x 8` | `-x 8` |
| Custom headers | `--header "..."` | `-H "..."` |
| Interactive mode | N/A | `gosh` (TUI) |
| Background daemon | `aria2c --enable-rpc` | Coming soon |

## Examples

### Download a File

```bash
# Simple download
gosh https://example.com/file.zip

# Download to specific directory
gosh -d ~/Downloads https://example.com/file.zip

# Download with custom filename
gosh -o myfile.zip https://example.com/file.zip
```

### Batch Downloads

```bash
# Multiple URLs
gosh https://example.com/file1.zip https://example.com/file2.zip

# From file
gosh add -i urls.txt

# Pipe from stdin
cat urls.txt | gosh add -
```

### BitTorrent

```bash
# Magnet link
gosh "magnet:?xt=urn:btih:..."

# Torrent file
gosh ubuntu-24.04.torrent

# Select specific files
gosh --select-files 0,1,2 multi-file.torrent

# Sequential for streaming
gosh --sequential movie.torrent
```

### Scripting

```bash
# JSON output for parsing
gosh list --output json | jq '.[] | .id'

# Check download status
if gosh status abc123 --output json | jq -e '.state == "Completed"'; then
  echo "Download finished!"
fi

# Monitor progress
gosh add -w https://example.com/large-file.iso
```

## Building from Source

```bash
# Development build
cargo build

# Release build
cargo build --release

# Run tests
cargo test

# Run with verbose logging
RUST_LOG=debug cargo run -- https://example.com/file.zip
```

## Requirements

- Rust 1.75+ (for async trait support)
- Linux, macOS, or Windows

## License

MIT License - see [LICENSE](LICENSE) for details.

## Related Projects

- [gosh-dl]https://github.com/goshitsarch-eng/gosh-dl - The underlying download engine library
- [docs.rs/gosh-dl-cli]https://docs.rs/gosh-dl-cli - API documentation