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

Commit e20d3f9

Browse files
author
Irene
committed
Add functionality to config command
Enable changing server address Enable toggling sending diagnostics Only allow certain keys - server address - send diagnostics - update date - progress/test bar colors
1 parent ec649e9 commit e20d3f9

9 files changed

Lines changed: 297 additions & 81 deletions

File tree

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

src/main/java/fi/helsinki/cs/tmc/cli/backend/Account.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class Account {
2323

2424
// for gson
2525
public Account() {
26-
this.serverAddress = "";
26+
this.serverAddress = DEFAULT_SERVER;
2727
}
2828

2929
public Account(String username, String password) {

0 commit comments

Comments
 (0)