Skip to content

Commit 0aec935

Browse files
committed
Small fixes
1 parent e886ee0 commit 0aec935

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/commands/command_util.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::path::Path;
44
use std::path::PathBuf;
55

66
use std::env;
7-
use std::str::FromStr;
87
use tmc_client::response::{
98
Course, CourseDetails, CourseExercise, ExercisesDetails, NewSubmission, Organization,
109
SubmissionFinished,
@@ -71,10 +70,12 @@ pub trait Client {
7170
) -> Result<NewSubmission, String>;
7271
}
7372

73+
static SERVER_ADDRESS: &str = "https://tmc.mooc.fi";
74+
7475
impl ClientProduction {
7576
pub fn new(test_mode: bool) -> Self {
7677
let (tmc_client, _credentials) = tmc_langs::init_tmc_client_with_credentials(
77-
Url::from_str("https://tmc.mooc.fi").expect(""),
78+
Url::parse(SERVER_ADDRESS).expect("Server address should always be correct."),
7879
PLUGIN,
7980
"1.0.0",
8081
)
@@ -168,8 +169,10 @@ impl Client for ClientProduction {
168169

169170
if let Some(credentials) = get_credentials() {
170171
self.tmc_client.set_token(credentials.token());
172+
Ok(())
173+
} else {
174+
Err("No login found. You need to be logged in to use this command".to_string())
171175
}
172-
Err("No login found. You need to be logged in to use this command".to_string())
173176
}
174177

175178
fn try_login(&mut self, username: String, password: String) -> Result<String, String> {

0 commit comments

Comments
 (0)