You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+92-17
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,29 @@ A command-line tool intended to insert a conditional compilation statement in mu
6
6
7
7
And generic enough being able to process multiple files and **insert *any* text at the top and the bottom of a file** :)
8
8
9
-
## if os()
9
+
## Find files with compiler directive (`#if ... #endif`) hugging the file content
10
10
11
-
Example:
11
+
```bash
12
+
swift run conditional-files find .
13
+
```
14
+
15
+
## Find and remove hugging compilerdirective
12
16
13
17
```bash
14
-
swift run conditional-files --ios test.swift
18
+
swift run conditional-files find .| xargs swift run conditional-files remove
15
19
```
16
20
21
+
## Add `#if os() ... #endif` to all files in (sub) directory
22
+
23
+
Set one or more respective flags, e.g. for iOS use `--ios`.
24
+
25
+
Pass a single dot (`.`) as argument to process all files in the current directory and subdirectories.
26
+
27
+
Example: `swift run conditional-files --ios .`
28
+
17
29
<table>
18
30
<tr>
19
-
<td> File (before) </td> <td> File (after) </td>
31
+
<td> File (before) </td> <td> File (after)
20
32
</tr>
21
33
<tr>
22
34
<td>
@@ -40,9 +52,41 @@ import CarKey
40
52
</tr>
41
53
</table>
42
54
43
-
You can process all files in the current directory and its sub-folders by specifying a single dot (`.`) as argument. Example: `swift run conditional-files --ios .`
55
+
You can add multiple statements by adding multiple flags.
44
56
45
-
You can also remove an existing compiler directive.
57
+
```bash
58
+
swift run conditional-files --ios --watchos .
59
+
```
60
+
61
+
<table>
62
+
<tr>
63
+
<td> File (before) </td> <td> File (after)
64
+
</tr>
65
+
<tr>
66
+
<td>
67
+
68
+
```swift
69
+
importCarKey
70
+
// code
71
+
```
72
+
73
+
</td>
74
+
<td>
75
+
76
+
```swift
77
+
#ifos(iOS) ||os(watchOS)
78
+
importCarKey
79
+
// code
80
+
#endif
81
+
```
82
+
83
+
</td>
84
+
</tr>
85
+
</table>
86
+
87
+
## Remove `#if os() ... #endif`
88
+
89
+
You can remove an existing compiler directive with flag `remove`.
46
90
47
91
```bash
48
92
swift run conditional-files --ios --undo test.swift
@@ -74,17 +118,18 @@ import CarKey
74
118
</tr>
75
119
</table>
76
120
77
-
## if os() || os() ...
78
121
79
-
You can add multiple statements.
122
+
## Add `#if os() ... #endif` to specific file(s)
123
+
124
+
Pass one or more file paths as arguments.
80
125
81
126
```bash
82
-
swift run conditional-files --ios --watchos test.swift
127
+
swift run conditional-files --ios test.swift
83
128
```
84
129
85
130
<table>
86
131
<tr>
87
-
<td> File (before) </td> <td> File (after)
132
+
<td> File (before) </td> <td> File (after) </td>
88
133
</tr>
89
134
<tr>
90
135
<td>
@@ -98,7 +143,7 @@ import CarKey
98
143
<td>
99
144
100
145
```swift
101
-
#ifos(iOS)||os(watchOS)
146
+
#ifos(iOS)
102
147
importCarKey
103
148
// code
104
149
#endif
@@ -108,9 +153,9 @@ import CarKey
108
153
</tr>
109
154
</table>
110
155
111
-
## if !os()
156
+
## Add `#if !os() ... #endif`
112
157
113
-
You can negate the #if(os) directive.
158
+
You can negate the #if(os) directive with command `not-os`.
114
159
115
160
```bash
116
161
swift run conditional-files not-os --ios --watchos test.swift
@@ -142,9 +187,7 @@ import CarKey
142
187
</tr>
143
188
</table>
144
189
145
-
## any (generic)
146
-
147
-
You can also add any top/bottom lines.
190
+
## Add `#if DEBUG ... #endif`
148
191
149
192
```text
150
193
swift run conditional-files generic --first-line '#if DEBUG' --last-line \#endif test.swift
@@ -174,4 +217,36 @@ import CarKey
174
217
175
218
</td>
176
219
</tr>
177
-
</table>
220
+
</table>
221
+
222
+
## Add any (generic) top & bottom line
223
+
224
+
You can also add any top & bottom lines.
225
+
226
+
```text
227
+
swift run conditional-files generic --first-line BEGIN --last-line END test.swift
0 commit comments