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

Commit d653793

Browse files
authored
Merge pull request #396 from testmycode/oauth
Oauth
2 parents 3e90d52 + e5d52f0 commit d653793

43 files changed

Lines changed: 1146 additions & 305 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ dependency-reduced-pom.xml
2828
# our tmc-cli log files
2929
/logs/
3030

31-
tmc-langs.logl
31+
tmc-langs.log
32+
/.classpath
33+
/.project
34+
/.settings

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ after_success:
77
- mvn clean package
88
jdk:
99
- oraclejdk8
10-
- oraclejdk7
1110
cache:
1211
directories:
1312
- "$HOME/.m2"

docs/HACKING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ public class ExampleCommandTest {
105105

106106
If you are doing tests for any other class, simply create normal unit tests that don't depend on any command.
107107

108-
##Adding properties
108+
## Adding properties
109109

110110
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.
111111

112-
##Updating the documentation
112+
## Updating the documentation
113113

114114
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.
115115

116116
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.
117117

118-
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).
118+
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: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -40,62 +40,59 @@ OPTIONS
4040
---
4141
COMMANDS
4242
---
43-
43+
4444
---
4545

4646
COMMAND: LOGIN
4747
-----
4848

49-
`tmc` `login` [`-s` *server address*] [`-u` *username*] [`-p` *password*]
49+
`tmc` `login` [`-u` *username*] [`-p` *password*]
5050

5151
Login to TMC server. If credentials are not given as options, the user will
5252
be asked to input any missing credentials. You will have to be logged in
5353
in order to use certain commands.
54-
55-
`-s` `--server`
56-
Specify which server to connect to.
57-
54+
5855
`-u` `--user`
5956
Specify username.
60-
57+
6158
`-p` `--password`
6259
Specify password.
63-
60+
6461
COMMAND: LOGOUT
6562
---------------
6663

6764
`tmc` `logout`
6865

6966
Delete login credentials from configurations.
70-
67+
7168
COMMAND: COURSES
7269
----------------
7370

7471
`tmc` `courses`
7572

7673
List all available courses on the server.
77-
74+
7875
COMMAND: DOWNLOAD
7976
-----------------
80-
77+
8178
`tmc` `download` [`-a`] *course*
8279

8380
Download a course from the server.
84-
81+
8582
`-a` `--all`
8683
Download all exercises, including completed ones.
87-
84+
8885
COMMAND: EXERCISES
8986
------------------
9087

9188
`tmc` `exercises` [`-n`] [`-i`]
9289

9390
List the status of all of the course's exercises. Exercises are grouped by
9491
their deadlines. On Unix, the list is displayed on a pager.
95-
92+
9693
`-n` `--no-pager`
9794
Print the list directly to the terminal.
98-
95+
9996
`-i` `--internet`
10097
Fetch exercises' statuses from the server, as opposed to reading from the
10198
local cache.
@@ -106,7 +103,7 @@ COMMAND: UPDATE
106103
`tmc` `update`
107104

108105
Update the course cache and download newly available exercises.
109-
106+
110107
COMMAND: TEST
111108
-------------
112109

@@ -116,7 +113,7 @@ Run tests for the specified exercise. If no *path* is given, tests will be
116113
run in the current working directory. Several exercises can be tested at once.
117114
If the current work directory is the course root directory or the course root
118115
directory was given as a *path*, then all exercises will be tested.
119-
116+
120117
`-a` `--all`
121118
Display all test results, instead of only the failed tests.
122119

@@ -136,16 +133,16 @@ course root directory was given as a *path*, then all exercises will be submitte
136133
For every successful submission, you'll be prompted to send feedback for the
137134
exercise if the course has enabledfeedback questions. Sending feedback is
138135
always optional.
139-
136+
140137
`-a` `--all`
141138
Display all test results, instead of only the failed tests.
142-
139+
143140
`-d` `--details`
144141
Display more detailed error messages.
145-
142+
146143
`-c` `--completed`
147144
Submit all exercises in the current course which have passed local tests.
148-
145+
149146
COMMAND: INFO
150147
-------------
151148

@@ -154,7 +151,7 @@ COMMAND: INFO
154151
Display the current status of a course or an exercise. If used for a course,
155152
shows the total amount of available, completed and locked exercises. If used
156153
for an exercise, shows the exercise's status and deadline.
157-
154+
158155
`-a` `--all`
159156
Displays all information for given course and exercises.
160157

@@ -174,30 +171,43 @@ Once submission is successful, a shareable link will be printed.
174171

175172
`-n` `--no-message`
176173
Do not send a message alongside the paste.
177-
174+
178175
`-m` `--message`
179176
Give the message as an argument instead of opening a text editor.
180177

181-
COMMAND: PROP
178+
COMMAND: CONFIG
182179
-------------
183180

184-
`tmc` `prop` [*KEY*] [*VALUE*] ...
185-
`prop` `-u` *KEY* ...
181+
`tmc` `config` `[-q]`[*KEY=VALUE*] ...
182+
`config` `-d` `[-q]` [*KEY*] ...
183+
`config` `-l`
184+
`config` `-g` [*KEY*] or `-g`=[*KEY*]
186185

187-
Set or unset TMC-CLI properties. Invoke without any arguments to display all
188-
current properties. If more than a single property is added or removed, the user
189-
will be asked to confirm the changes.
190-
191-
`-u` `--unset`
186+
Set or unset TMC-CLI properties. Only accepts certain keys. If not invoked with the option `quiet` will ask to confirm changes.
187+
188+
`-d` `--delete`
192189
Unset given properties.
193-
194-
List of properties:
195-
190+
191+
`-q` `--quiet`
192+
Do not ask for confirmations or print out set values.
193+
194+
`-l` `--list`
195+
List all current properties.
196+
197+
`-g` `--get=KEY` or `--get KEY`
198+
Get the value of a specific key.
199+
200+
List of configurable settings:
201+
196202
* *update-date*
197-
Scheduled time for the next version check.
203+
Scheduled time for the next version check. Stored in properties.
198204
* *testresults-left* *testresults-right* *progressbar-left* *progressbar-right*
199205
Change progress bar colours. Recognised values: black, red, green, yellow,
200-
blue, purple, cyan, white, none.
206+
blue, purple, cyan, white, none. Stored in properties.
207+
* *send-diagnostics*
208+
Allow sending crash reports and analytics for client development. Stored with account.
209+
* *server-address*
210+
Address to fetch courses from and submit to. Defaults to `https://tmc.mooc.fi`. Stored with account
201211

202212
---
203213

@@ -207,17 +217,17 @@ FILES
207217
`[course directory]/.tmc.json`
208218
Course configuration and cache file. Saves the status of the username, server
209219
address and course's exercises. Manually editing this file may have adverse
210-
effects.
220+
effects.
211221

212222
`~/.config/tmc-cli/properties.json`
213223
User configuration file. Use `tmc prop` to edit properties.
214224

215225
`~/.config/tmc-cli/accounts.json`
216226
User login credentials. Use `tmc logout` to safely delete.
217-
227+
218228
`~/.config/tmc-cli/logs/tmc-cli.log`
219229
Debug logging.
220-
230+
221231
For more on config locations, see `ENVIRONMENT` -> `XDG_CONFIG_HOME` and `APPDATA`.
222232

223233
ENVIRONMENT
@@ -230,10 +240,10 @@ ENVIRONMENT
230240
`PAGER`
231241
Pager for displaying text files. If unset, defaults to `less -R` on Unix.
232242
This functionality is broken on Windows, but defaults to `more`.
233-
243+
234244
`XDG_CONFIG_HOME`
235245
If set on Unix, *~/.config/* in config file paths is replaced with its value.
236-
246+
237247
`APPDATA`
238248
On Windows, *~/.config/* is replaced with the value of `%APPDATA%`, usually
239249
*C:\\Users\\Username\\AppData\\Roaming\\.* If `%APPDATA%` is unset, user's home

pom.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<packaging>jar</packaging>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10-
<maven.compiler.source>1.7</maven.compiler.source>
11-
<maven.compiler.target>1.7</maven.compiler.target>
12-
<powermock.version>1.5.1</powermock.version>
10+
<maven.compiler.source>1.8</maven.compiler.source>
11+
<maven.compiler.target>1.8</maven.compiler.target>
12+
<powermock.version>1.7.3</powermock.version>
1313
</properties>
1414

1515
<repositories>
@@ -36,7 +36,7 @@
3636
<dependency>
3737
<groupId>fi.helsinki.cs.tmc</groupId>
3838
<artifactId>core</artifactId>
39-
<version>0.9.1-SNAPSHOT</version>
39+
<version>0.10.3-SNAPSHOT</version>
4040
</dependency>
4141
<dependency>
4242
<groupId>commons-cli</groupId>
@@ -46,23 +46,24 @@
4646
<dependency>
4747
<groupId>com.google.code.gson</groupId>
4848
<artifactId>gson</artifactId>
49-
<version>2.6.2</version>
49+
<version>2.8.2</version>
5050
<scope>compile</scope>
5151
</dependency>
5252
<dependency>
5353
<groupId>org.slf4j</groupId>
5454
<artifactId>slf4j-api</artifactId>
55-
<version>1.7.21</version>
55+
<version>1.7.25</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>org.slf4j</groupId>
5959
<artifactId>slf4j-log4j12</artifactId>
60-
<version>1.7.21</version>
60+
<version>1.7.25</version>
6161
</dependency>
6262
<dependency>
6363
<groupId>org.mockito</groupId>
6464
<artifactId>mockito-all</artifactId>
6565
<version>1.10.19</version>
66+
<scope>test</scope>
6667
</dependency>
6768
<dependency>
6869
<groupId>commons-io</groupId>
@@ -115,8 +116,8 @@
115116
<artifactId>maven-compiler-plugin</artifactId>
116117
<version>3.5.1</version>
117118
<configuration>
118-
<source>1.7</source>
119-
<target>1.7</target>
119+
<source>${maven.compiler.source}</source>
120+
<target>${maven.compiler.source}</target>
120121
<compilerArgument>-Xlint:unchecked</compilerArgument>
121122
</configuration>
122123
<executions>
@@ -204,9 +205,7 @@
204205
<encoding>UTF-8</encoding>
205206
<linkXRef>false</linkXRef>
206207
<failOnViolation>true</failOnViolation>
207-
<configuration>
208208
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
209-
</configuration>
210209
</configuration>
211210
<dependencies>
212211
<dependency>
@@ -257,6 +256,7 @@
257256

258257
<profiles>
259258
<profile>
259+
<id>dev</id>
260260
<activation>
261261
<os>
262262
<family>!windows</family>

src/main/java/fi/helsinki/cs/tmc/cli/Application.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
import org.slf4j.Logger;
2121
import org.slf4j.LoggerFactory;
2222

23-
import java.util.ArrayList;
24-
import java.util.Arrays;
25-
import java.util.Date;
23+
import java.lang.management.ManagementFactory;
2624
import java.util.List;
2725
import java.util.Map;
2826
import java.util.Set;
27+
import java.util.Scanner;
28+
import java.util.Date;
29+
import java.util.ArrayList;
30+
import java.util.Arrays;
2931

3032
/**
3133
* The application class for the program.
@@ -80,7 +82,8 @@ public Application(CliContext context) {
8082
}
8183

8284
private boolean runCommand(String name, String[] args) {
83-
AbstractCommand command = CommandFactory.createCommand(name);
85+
String[] commandName = name.split(" ");
86+
AbstractCommand command = CommandFactory.createCommand(commandName[0].trim().toLowerCase());
8487
if (command == null) {
8588
io.errorln("Command " + name + " doesn't exist.");
8689
return false;
@@ -175,6 +178,7 @@ public void run(String[] args) {
175178
}
176179
}
177180

181+
178182
public static void main(String[] args) {
179183
Application app = new Application(new CliContext(null));
180184
app.run(args);

0 commit comments

Comments
 (0)