Skip to content

Commit 7e75b79

Browse files
committed
Code formatted using rustfmt format
1 parent 7ba41f2 commit 7e75b79

6 files changed

Lines changed: 10 additions & 26 deletions

File tree

src/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use login_command::login;
33
use logout_command::logout;
44
use organization_command::organization;
55
mod command_util;
6-
mod organization_command;
76
mod download_command;
87
mod login_command;
98
mod logout_command;
9+
mod organization_command;
1010

1111
use crate::io_module::IO;
1212

src/commands/command_util.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
use tmc_client::TmcClient;
21
use crate::config::Credentials;
32
use std::path::PathBuf;
3+
use tmc_client::TmcClient;
44

55
pub const PLUGIN: &str = "vscode_plugin";
66

7-
87
pub fn get_client() -> TmcClient {
98
TmcClient::new(
109
PathBuf::from("./config"),
@@ -23,6 +22,3 @@ pub fn get_credentials() -> Option<Credentials> {
2322
pub fn is_logged_in() -> bool {
2423
get_credentials().is_some()
2524
}
26-
27-
28-

src/commands/download_command.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use crate::io_module::IO;
2-
use tmc_client::TmcClient;
1+
use super::command_util::*;
32
use crate::config::Credentials;
3+
use crate::io_module::IO;
44
use std::path::PathBuf;
5-
use super::command_util::*;
5+
use tmc_client::TmcClient;
66

77
pub fn download_or_update(io: &mut IO) {
8-
98
if !is_logged_in() {
109
io.println("Not logged in. Login before downloading exerises");
1110
return;
@@ -29,7 +28,6 @@ pub fn download_or_update(io: &mut IO) {
2928
// Load login credentials if they exist in the file
3029
let credentials = get_credentials().unwrap();
3130
client.set_token(credentials.token()).unwrap();
32-
3331

3432
// Build a vector for exercise id and saving location pairs
3533
let mut download_params = Vec::new();

src/commands/login_command.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
use super::command_util::*;
2+
use super::organization_command::set_organization;
13
use crate::config::Credentials;
24
use crate::io_module::IO;
35
use std::path::PathBuf;
46
use tmc_client::{ClientError, TmcClient};
5-
use super::command_util::*;
6-
use super::organization_command::set_organization;
7-
87

98
pub fn login(io: &mut IO) {
109
if is_logged_in() {
@@ -30,8 +29,6 @@ pub fn login(io: &mut IO) {
3029
io.println(authenticate(username, password));
3130

3231
set_organization(io);
33-
34-
3532
}
3633

3734
fn authenticate(username: String, password: String) -> &'static str {
@@ -51,7 +48,6 @@ fn authenticate(username: String, password: String) -> &'static str {
5148
"Something funny happened"
5249
}
5350

54-
5551
fn explain_login_fail(error: ClientError) -> &'static str {
5652
let res = format!("{:?}", error);
5753

src/commands/logout_command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use super::command_util::*;
12
use crate::config::Credentials;
23
use crate::io_module::IO;
34
use std::path::PathBuf;
45
use tmc_client::TmcClient;
5-
use super::command_util::*;
66

77
pub fn logout(io: &mut IO) {
88
if !is_logged_in() {

src/commands/organization_command.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1+
use super::command_util::*;
12
use crate::io_module::IO;
3+
use anyhow::Result;
24
use std::path::PathBuf;
3-
use super::command_util::*;
45
use tmc_langs_framework::file_util;
5-
use anyhow::{Result};
6-
76

87
pub fn get_organization_path(client_name: &str) -> Result<PathBuf> {
98
crate::config::get_tmc_dir(client_name).map(|dir| dir.join("organization.json"))
109
}
1110

12-
13-
1411
// Returns none if no valid organization slug can be read from file,
1512
// otherwise organization slug as string
1613
pub fn check_organization(client_name: String) -> Option<String> {
1714
// TBD Read organization from file
1815
// for now just return mooc
1916
Some("mooc".to_string())
20-
2117
}
2218

2319
// Asks for organization from user and saves it into file
2420
pub fn set_organization(io: &mut IO) -> Result<()> {
25-
2621
// List all organizations
2722
for orgs in get_client().get_organizations() {
2823
for org in orgs {
@@ -39,7 +34,6 @@ pub fn set_organization(io: &mut IO) -> Result<()> {
3934
// TBD: Save organization into file here
4035
io.println("TBD: SAVING ORGANIZATION INTO FILE");
4136
Ok(())
42-
4337
}
4438

4539
// Check if logged in, then ask for organization

0 commit comments

Comments
 (0)