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

Commit d0ee1df

Browse files
author
mikkomaa
authored
Merge branch 'master' into redo-multi-login-support-aleksi
2 parents 936bdf1 + 7c42d0c commit d0ee1df

File tree

4 files changed

+50
-35
lines changed

4 files changed

+50
-35
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@ If you downloaded "tmc", navigate to the download directory on your terminal and
3131
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.
3232

3333
To summarise:
34+
3435
```
3536
~ $ chmod u+x tmc
3637
~ $ ./tmc
3738
~ $ . ~/.bashrc
3839
~ $ echo "Now you can run tmc anywhere."
3940
```
4041

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.
4243

4344
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).)
4445

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.
4647

4748
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`.
4849

@@ -57,6 +58,7 @@ For system administrators/packagers: To make the man page available for all user
5758
##Logging in
5859

5960
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+
6062
```
6163
~ $ tmc login
6264
server address:
@@ -76,11 +78,12 @@ algorithms-101
7678
c-mooc
7779
javascript-for-lazy-hipsters
7880
```
81+
7982
Note that you can only submit exercises on courses for which you have enrolled.
8083

8184
##Downloading courses
8285

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`.
8487

8588
```
8689
~ $ mkdir tmc-courses; cd tmc-courses
@@ -91,6 +94,7 @@ Downloading: test-course
9194
~/tmc-courses/test-course $ ls -pa
9295
exercise1/ exercise2/ exercise3/ exercise4/ .tmc.json
9396
```
97+
9498
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.
9599

96100
##Running tests

docs/HACKING.md

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

44
## 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)
77

88

99
## Building tmc-cli
@@ -14,34 +14,23 @@ To build tmc-cli run the appropriate Maven command.
1414

1515
## Architecture
1616

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.
1918

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.
2320

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).
2822

2923
### Important classes
3024

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.
3426

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.
3728

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/).
3930

4031
## Creating new commands
4132

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.
4534

4635
Please create all new commands inside the `command` package.
4736

@@ -56,17 +45,15 @@ public class ExampleCommand extends AbstractCommand {
5645
}
5746
```
5847

48+
Document *all* commands and their options in MANUAL.md (read below for more on documentation).
49+
5950
## Logging error messages
6051

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.
6453

6554
## Unit testing
6655

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.
7057

7158
```java
7259
@RunWith(PowerMockRunner.class)
@@ -113,5 +100,16 @@ public class ExampleCommandTest {
113100
}
114101
```
115102

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).

docs/MANUAL.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
TMC-CLI 1 2016-06-30 "Helsinki Univ. Dep. of CS" "TMC-CLI Manual"
2-
=================================================================
1+
TMC-CLI 1 2016-06-30 "TestMyCode" "TMC-CLI Manual"
2+
==================================================
33

44
NAME
55
----
@@ -207,8 +207,7 @@ FILES
207207
`[course directory]/.tmc.json`
208208
Course configuration and cache file. Saves the status of the username, server
209209
address and course's exercises. Manually editing this file may have adverse
210-
effects.
211-
210+
effects.
212211

213212
`~/.config/tmc-cli/properties.json`
214213
User configuration file. Use `tmc prop` to edit properties.

scripts/install.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#bin/sh
2+
3+
curl -O https://github.com/tmc-cli/tmc-cli/releases/download/0.6.3/tmc
4+
chmod u+x ./tmc
5+
if ./tmc ;then
6+
echo Error when installing.
7+
exit 1
8+
fi
9+
10+
11+
source $HOME/.bashrc
12+
13+
echo Installation complete.
14+
exit 0

0 commit comments

Comments
 (0)