Skip to content

Commit ac71a3d

Browse files
Add docs for file actions
1 parent 5330d0f commit ac71a3d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

docs/source/usage.rst

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ the pages below:
1111

1212
usage/graders/writing_graders
1313
usage/graders/examples
14+
usage/file-actions

docs/source/usage/file-actions.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# File Actions
2+
3+
File actions are Tin's way of running commands on the files of an assignment.
4+
5+
For example, say you have a Java file used in a grader, and you wanted to compile
6+
it into a `.class` file. Instead of compiling the java file locally and uploading
7+
the class file to Tin each time you change it, you can upload the Java file to
8+
Tin and use a file action to compile it to a `.class` file.
9+
10+
## The File Action Marketplace
11+
When viewing a course, there will be a button called "Manage File Actions". This will take you to the
12+
File Action Marketplace, where you can see every file action created across courses, or create your
13+
own file action. We **strongly recommend** checking if a file action that suits your needs can be found
14+
in the marketplace before creating your own.
15+
16+
After adding a file action to your course, you can edit it, copy it, or remove it from your course
17+
by hovering over it.
18+
19+
## File Action Commands
20+
Let's take the previous example of compiling all `.java` files uploaded to Tin.
21+
To do that, we need to:
22+
23+
1. Find all files _ending_ with `.java`
24+
2. Run `javac <space separated filenames>`
25+
26+
To do this, we can create a file action with
27+
28+
- Match type set to "Ends with"
29+
- Match value set to `.java`
30+
- The command set to `javac $FILES`
31+
32+
```{note}
33+
For security reasons, the command does not have the same capabilities
34+
as a full shell. For example, redirections, heredocs, or command substitutions
35+
are not possible. Instead, think of the command is being run in a subprocess.
36+
```
37+
38+
## `$FILE` vs `$FILES`
39+
In some cases, the need may arise to call a command on every
40+
matching file, instead of a space separated list of filenames. In such
41+
a case, one can use `$FILE` instead of `$FILES`.
42+
43+
To illustrate, suppose we had the following directory structure:
44+
```
45+
.
46+
├── Bar.java
47+
├── data.txt
48+
└── Foo.java
49+
```
50+
Then, assuming that the match value is set to ending with `.java`,
51+
52+
- Setting the command to `javac $FILES` would run `javac Bar.java Foo.java`
53+
- Setting the command to `javac $FILE` would first run `javac Bar.java` and after that, `javac Foo.java`

0 commit comments

Comments
 (0)