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
//! Argument definitions for the apply command.
use Facet;
/// Arguments for the `apply` command.
///
/// The apply command reads patches from a JSON file (or stdin) and applies
/// them to their target files. This is the programmatic interface for textum,
/// suitable for complex patch operations and tool integration.
///
/// # JSON Format
///
/// The JSON should be an array of patch objects:
/// ```json
/// [
/// {
/// "file": "src/main.rs",
/// "snippet": {
/// "At": {
/// "target": {"Literal": "old"},
/// "mode": "Include"
/// }
/// },
/// "replacement": "new"
/// }
/// ]
/// ```
///
/// # Examples
///
/// Apply from file:
/// ```bash
/// textum apply patches.json
/// ```
///
/// Apply from stdin:
/// ```bash
/// echo '[...]' | textum apply
/// ```
///
/// Preview changes:
/// ```bash
/// textum apply patches.json --dry-run --diff
/// ```