Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit aafbe81

Browse files
author
Aleksi Salmela
committed
Update the hacking document.
1 parent 0c0c0ea commit aafbe81

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

HACKING.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Hacking the tmc-cli
2-
===================
1+
Architecture and Hacking the tmc-cli
2+
====================================
33

44
## Requirements for developing tmc-cli
55
* jdk 7
@@ -12,6 +12,31 @@ To build tmc-cli run the appropriate Maven command.
1212
$ git clone https://github.com/tmc-cli/tmc-cli.git
1313
$ mvn clean install
1414

15+
## Architecture
16+
17+
Program architecture is based on command design pattern. The program runs only a single command
18+
on each program execution.
19+
20+
Conceptually, there are three main parts in the program; the launch code, backend related code
21+
and the commands. The commands are gathered into their own package. In addition, there are utility
22+
classes in order to take care of user input/output and file handling.
23+
24+
The tmc-cli itself is mostly just an command line interface for the backend libraries.
25+
All the heavy lifting is done by [tmc-core](https://github.com/testmycode/tmc-core) and
26+
[tmc-langs](https://github.com/testmycode/tmc-langs) libraries. The tmc-cli also requires the
27+
server-side component of TestMyCode aka. [tmc-server](https://github.com/testmycode/tmc-server).
28+
29+
### Important classes
30+
31+
The `CliContext` object contains some cached data and singleton objects that are commonly used
32+
by utility classes and commands. Most importantly it has the `Io` object which is responsible
33+
for printing messages for the user and helping with other user interactions.
34+
35+
The `WorkDir` object handles most of the directory path handling. And it's used by most
36+
commands to parse the exercise arguments.
37+
38+
The `TmcUtil` class has wraps all tmc-cores functions into nicer interfac.
39+
1540
## Creating new commands
1641

1742
Every command must have `@Command` annotation and it's highly recommended to extend the
@@ -31,13 +56,6 @@ public class ExampleCommand extends AbstractCommand {
3156
}
3257
```
3358

34-
## Architecture
35-
36-
Tmc-cli architecture is based on running only a single command on each program execution.
37-
Commands use the utility classes in other packages. The `CliContext` object contains some cached
38-
objects that are commonly used by utility classes and commands. Most importantly it has the `Io`
39-
object which is responsible for printing messages for the user and helping with other user interactions.
40-
4159
## Logging error messages
4260

4361
In case of failure, please print debug info in the error log by using slf4j logger and print some
@@ -53,7 +71,7 @@ assert method prints easily understandable error messages when it fails and does
5371
```java
5472
@RunWith(PowerMockRunner.class)
5573
@PrepareForTest(TmcUtil.class)
56-
public class ExampleCommand {
74+
public class ExampleCommandTest {
5775

5876
private Application app;
5977
private CliContext ctx;

0 commit comments

Comments
 (0)