Skip to content

Commit 32c00e7

Browse files
author
Colin Wahl
committed
add docs for IO
1 parent 762017d commit 32c00e7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

docs/04-IO.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# GitHub.Actions.IO
2+
3+
> Core functions for cli filesystem scenarios
4+
5+
This module exposes bindings to the [@actions/io package](https://github.com/actions/toolkit/tree/main/packages/io).
6+
7+
## Usage
8+
9+
#### mkdir -p
10+
11+
Recursively make a directory. Follows rules specified in [man mkdir](https://linux.die.net/man/1/mkdir) with the `-p` option specified:
12+
13+
```purescript
14+
IO.mkdirP { fsPath: "path/to/make" }
15+
```
16+
17+
#### cp/mv
18+
19+
Copy or move files or folders. Follows rules specified in [man cp](https://linux.die.net/man/1/cp) and [man mv](https://linux.die.net/man/1/mv):
20+
21+
```purescript
22+
// Recursive must be true for directories
23+
const options = { recursive: true, force: false }
24+
25+
let copyOptions = { recursive: Just true, foce: Just false }
26+
27+
IO.cp { source: "path/to/directory", dest: "path/to/dest", options: Just copyOptions }
28+
IO.mv { source: "path/to/file", dest: "path/to/dest" }
29+
```
30+
31+
#### rm -rf
32+
33+
Remove a file or folder recursively. Follows rules specified in [man rm](https://linux.die.net/man/1/rm) with the `-r` and `-f` rules specified.
34+
35+
```purescript
36+
IO.rmRF { inputPath: "path/to/directory" }
37+
```
38+
39+
#### which
40+
41+
Get the path to a tool and resolves via paths. Follows the rules specified in [man which](https://linux.die.net/man/1/which).
42+
43+
```purescript
44+
example = do
45+
pythonPath <- IO.which' "python"
46+
Exec.exec { command: pythonPath, args: Just [ "main.py" ], options: Nothing }
47+
```

0 commit comments

Comments
 (0)