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
{{ message }}
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,18 +31,19 @@ If you downloaded "tmc", navigate to the download directory on your terminal and
31
31
Launch tmc once with `./tmc`. Running tmc-cli for the first time will add an alias to your .bashrc, enabling you to use tmc-cli by invoking the command `tmc`. For the alias to come into effect, execute `. ~/.bashrc` or simply open a new terminal.
32
32
33
33
To summarise:
34
+
34
35
```
35
36
~ $ chmod u+x tmc
36
37
~ $ ./tmc
37
38
~ $ . ~/.bashrc
38
39
~ $ echo "Now you can run tmc anywhere."
39
40
```
40
41
41
-
If for some reason the alias was not added to your .bashrc or your shell of choice is not Bash, you can manually add the following line `alias tmc="[PATH_TO_TMC]"` to your .bashrc / other shell rc file.
42
+
If for some reason nothing was added to your .bashrc or your shell of choice is not Bash, you can manually add the following line `source $HOME/.tmc-autocomplete.sh` (or `alias tmc="[PATH_TO_TMC]"` for tmc with no autocompletion) to your .bashrc / other shell rc file.
42
43
43
44
If you are using Windows and you downloaded the .jar file, you must use tmc-cli directly with Java like so: `java -jar [path_to_tmc-cli.jar]`. In the following examples, replace `tmc` with this command. (note: you must have set Java on your system `%PATH%`. For more information, see [this Java help page](https://www.java.com/en/download/help/path.xml).)
44
45
45
-
Tip: On Windows, use `doskey tmc="java -jar[path_to_tmc-cli.jar] $@"` to create a convenient alias.
46
+
Tip: On Windows, use `doskey tmc="java -jar [path_to_tmc-cli.jar] $*"` in cmd.exe or `doskey /exename=powershell.exe tmc="java -jar [path_to_tmc-cli.jar] $*"` in PowerShell to create a convenient alias.
46
47
47
48
Now that you've installed tmc-cli, you can view all available commands by running tmc without arguments or with `tmc --help`. You can also view all available options for commands by running them with the `--help` switch, for example `tmc courses --help`.
48
49
@@ -57,6 +58,7 @@ For system administrators/packagers: To make the man page available for all user
57
58
##Logging in
58
59
59
60
Once installation is complete, you can log in using `tmc login`. This saves your TMC login information to a configuration file in ~/.config/tmc-cli/ (or %APPDATA% on Windows) - you will only have to log in once.
61
+
60
62
```
61
63
~ $ tmc login
62
64
server address:
@@ -76,11 +78,12 @@ algorithms-101
76
78
c-mooc
77
79
javascript-for-lazy-hipsters
78
80
```
81
+
79
82
Note that you can only submit exercises on courses for which you have enrolled.
80
83
81
84
##Downloading courses
82
85
83
-
Navigate to a suitable directory in which you wish to download your course(s). Then, run `tmc download [COURSE_NAME]`. This will create a new directory for your course and download all available exercises into it.
86
+
Navigate to a suitable directory in which you wish to download your course(s). Then, run `tmc download [COURSE_NAME]`. This will create a new directory for your course and download all available exercises into it. By default, only exercises that you have not fully completed are downloaded - download all exercises with `-a`.
Course-specific information is stored in .tmc.json. Do not manually edit or remove it unless you are completely done with the course - doing so will cause tmc to not function properly.
Copy file name to clipboardExpand all lines: docs/HACKING.md
+26-28Lines changed: 26 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@ Architecture and Hacking the tmc-cli
2
2
====================================
3
3
4
4
## Requirements for developing tmc-cli
5
-
*jdk 7
6
-
*linux bash (mac's bash won't work)
5
+
*JDK 7
6
+
*Modern Linux Bash (Mac's Bash won't work)
7
7
8
8
9
9
## Building tmc-cli
@@ -14,34 +14,23 @@ To build tmc-cli run the appropriate Maven command.
14
14
15
15
## Architecture
16
16
17
-
Program architecture is based on command design pattern. The program runs only a single command
18
-
on each program execution.
17
+
Tmc-cli's program architecture is based on command design pattern. The program runs only a single command on each program execution.
19
18
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.
19
+
Conceptually, there are three main parts in the program; the launch code, backend related code and commands. The commands are gathered into their own package. In addition, there are utility classes for user input/output and file handling.
23
20
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).
21
+
Tmc-cli itself is mostly just an command line interface for the backend libraries. All the heavy lifting is done by [tmc-core](https://github.com/testmycode/tmc-core) and [tmc-langs](https://github.com/testmycode/tmc-langs) libraries. Tmc-cli also requires the server-side component of TestMyCode aka. [tmc-server](https://github.com/testmycode/tmc-server).
28
22
29
23
### Important classes
30
24
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.
25
+
The `CliContext` object contains some cached data and singleton objects that are commonly used by utility classes and commands. Most importantly, it has the `Io` object which handles all user interaction via terminal. Never print anything using System.out.print(), since tests use the `TestIo` class which is dependent on the `Io` interface.
34
26
35
-
The `WorkDir` object handles most of the directory path handling. And it's used by most
36
-
commands to parse the exercise arguments.
27
+
The `WorkDir` object handles most of the directory path handling. It is used by most commands to parse the exercise arguments.
37
28
38
-
The `TmcUtil` class has wraps all tmc-cores functions into nicer interfac.
29
+
The `TmcUtil` class is a static class with methods for interfacing with [tmc-core](https://github.com/testmycode/tmc-core/).
39
30
40
31
## Creating new commands
41
32
42
-
Every command must have `@Command` annotation and it's highly recommended to extend the
43
-
AbstractCommand class. Note that the `@Command` annotation is used for creating help messages
44
-
and its 'name' field is used as the sub-command name in terminal.
33
+
Every command must have `@Command` annotation and it's highly recommended to extend the AbstractCommand class. Note that the `@Command` annotation is used for creating help messages and its 'name' field is used as the sub-command name in terminal.
45
34
46
35
Please create all new commands inside the `command` package.
47
36
@@ -56,17 +45,15 @@ public class ExampleCommand extends AbstractCommand {
56
45
}
57
46
```
58
47
48
+
Document *all* commands and their options in MANUAL.md (read below for more on documentation).
49
+
59
50
## Logging error messages
60
51
61
-
In case of failure, please print debug info in the error log by using slf4j logger and print some
62
-
useful error messages to user with `ctx.getIo().println(' ... ');`. Ctx context object is
63
-
passed into most of the code in tmc-cli and you can use it to interact with the user.
52
+
In case of failure, please print debug info in the error log by using slf4j logger and print some useful error messages to user with `ctx.getIo().println(' ... ');`. Ctx context object is passed into most of the code in tmc-cli and you can use it to interact with the user.
64
53
65
54
## Unit testing
66
55
67
-
If you create a new command, please use integration tests only. If you want to verify that a command
68
-
or a utility class has printed text into the terminal, use `io.assertContains()` method. This custom
69
-
assert method prints easily understandable error messages when it fails and doesn't require much code.
56
+
If you create a new command, please use integration tests only. If you want to verify that a command or a utility class has printed text into the terminal, use `io.assertContains()` method. This custom assert method prints easily understandable error messages when it fails and doesn't require much code.
70
57
71
58
```java
72
59
@RunWith(PowerMockRunner.class)
@@ -113,5 +100,16 @@ public class ExampleCommandTest {
113
100
}
114
101
```
115
102
116
-
If you are doing tests for any other class, simply create normal unit tests
117
-
that don't depend on any command.
103
+
If you are doing tests for any other class, simply create normal unit tests that don't depend on any command.
104
+
105
+
##Adding properties
106
+
107
+
Properties are saved as a Java `HashMap<String, String>`. They are read from ~/.config/tmc-cli/properties.json on initialisation. The purpose of the properties file is to provide a backwards- and forwards-compatible method of storing user preferences and internal data. Properties can be accessed via the `CliContext` class method getProperties(). Remember to store any changes to the properties with saveProperties(). Feel free to create new properties, but please document *all* properties in the 'COMMAND: PROP'-section of MANUAL.md.
108
+
109
+
##Updating the documentation
110
+
111
+
Please document any new features or revisions in MANUAL.md and HISTORY.md as well as README.md, if the affected feature is already documented there.
112
+
113
+
If you make changes to MANUAL.md, please rebuild tmc.1 with [md2man](https://github.com/sunaku/md2man) before you push your changes. Use `md2man-roff docs/MANUAL.md > docs/tmc.1` to build the manpage.
114
+
115
+
There are no strict guidelines for README.md or MANUAL.md, but please try not to deviate from the original style (eg. new command sections should follow the same pattern).
0 commit comments