Skip to content

Commit f321faa

Browse files
committed
Update dependencies
Sort course list for a consistent display order Fix compiler errors being treated improperly Use tracing for logging
1 parent 4ae13b5 commit f321faa

File tree

11 files changed

+1680
-975
lines changed

11 files changed

+1680
-975
lines changed

Cargo.lock

Lines changed: 1475 additions & 806 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ anyhow = { version = "1.0.56", features = ["backtrace"] }
1919
bytes = "1.4.0"
2020
clap = { version = "4.0.7", features = ["derive"] }
2121
clap_complete = "4.0.2"
22-
crossterm = "0.26.0"
23-
flexi_logger = "0.25.3"
22+
crossterm = "0.28.1"
23+
flexi_logger = "0.29.0"
2424
indicatif = "0.17.1"
2525
log = "0.4.17"
26-
reqwest = { version = "0.11.9", default-features = false, features = [
26+
ratatui = { version = "0.28.1", default-features = false, features = [
27+
'crossterm',
28+
] }
29+
reqwest = { version = "0.12.7", default-features = false, features = [
2730
"blocking",
2831
"json",
2932
"rustls-tls",
@@ -33,10 +36,12 @@ rpassword = "7.0.0"
3336
serde = "1.0.136"
3437
serde_json = "1.0.79"
3538
termcolor = "1.1.3"
36-
terminal_size = "0.2.1"
37-
tmc-langs = { git = "https://github.com/rage/tmc-langs-rust", tag = "0.33.0" }
38-
toml = "0.7.2"
39-
tui = { version = "0.19.0", default-features = false, features = ['crossterm'] }
39+
terminal_size = "0.3.0"
40+
tmc-langs = { git = "https://github.com/rage/tmc-langs-rust", tag = "0.36.2" }
41+
toml = "0.8.19"
42+
tracing = "0.1.40"
43+
tracing-appender = "0.2.3"
44+
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
4045
url = "2.2.2"
4146
uuid = { version = "1.4.0", features = ["v4"] }
4247

@@ -52,3 +57,6 @@ clap_complete = "4.0.2"
5257

5358
# [patch."https://github.com/rage/tmc-langs-rust"]
5459
# tmc-langs = { path = "../tmc-langs-rust/crates/tmc-langs" }
60+
61+
# [patch.'https://github.com/rage/secret-project-331.git']
62+
# mooc-langs-api = { path = "../secret-project-331/services/headless-lms/langs-api" }

src/commands/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn login(
4646
}
4747

4848
if interactive_mode {
49-
download_after_login(client, io, config, &org)?;
49+
download_after_login(client, io, config, &org.slug)?;
5050
}
5151

5252
io.println("Logged in", PrintColor::Success)?;

src/commands/organization.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::{
44
interactive::{self, interactive_list},
55
io::{Io, PrintColor},
66
};
7+
use tmc_langs::tmc::response::Organization;
78

89
// Asks for organization from user and saves it into file
910
pub fn set_organization_old(
1011
io: &mut Io,
1112
client: &mut Client,
1213
config: &mut TmcCliConfig,
13-
) -> anyhow::Result<String> {
14+
) -> anyhow::Result<Organization> {
1415
// List all organizations
1516
let mut orgs = client.get_organizations()?;
1617
orgs.sort_by(|a, b| b.pinned.cmp(&a.pinned).then(b.name.cmp(&a.name)));
@@ -36,9 +37,9 @@ pub fn set_organization_old(
3637
let slug = io.read_line()?.trim().to_string();
3738

3839
if let Some(org) = orgs.into_iter().find(|org| org.slug == slug) {
39-
config.set_organization(org.slug);
40+
config.set_organization(org.slug.clone());
4041
config.save()?;
41-
return Ok(org.name);
42+
return Ok(org);
4243
}
4344

4445
anyhow::bail!("No such organization for the given slug: {}", slug);
@@ -48,7 +49,7 @@ pub fn set_organization(
4849
io: &mut Io,
4950
client: &mut Client,
5051
config: &mut TmcCliConfig,
51-
) -> anyhow::Result<String> {
52+
) -> anyhow::Result<Organization> {
5253
io.println("Fetching organizations...", PrintColor::Normal)?;
5354
let mut orgs = client.get_organizations()?;
5455
orgs.sort_by(|a, b| b.pinned.cmp(&a.pinned).then(a.name.cmp(&b.name)));
@@ -73,9 +74,9 @@ pub fn set_organization(
7374
};
7475

7576
if let Some(org) = orgs.into_iter().find(|org| org.name == org_name) {
76-
config.set_organization(org.slug);
77+
config.set_organization(org.slug.clone());
7778
config.save()?;
78-
return Ok(org.name);
79+
return Ok(org);
7980
}
8081

8182
anyhow::bail!("Something strange happened");
@@ -95,7 +96,7 @@ pub fn organization(
9596
};
9697

9798
io.println(
98-
&format!("Selected {org} as organization."),
99+
&format!("Selected {} as organization.", org.name),
99100
PrintColor::Success,
100101
)?;
101102
Ok(())

0 commit comments

Comments
 (0)