Skip to content

Commit

Permalink
feat: add support for the 'list' command
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed Aug 27, 2024
1 parent 6745b17 commit 1da9b38
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod build;
pub mod default;
pub mod install;
pub mod list;
pub mod releases;
pub mod switch;
pub mod update_links;
5 changes: 5 additions & 0 deletions src/cmd/list.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::config;

pub fn run(config: &config::Config) {
config::print_ids(config);
}
14 changes: 14 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ pub struct LanguageConfig {
installs: toml::Table,
}

pub fn print_ids(config: &Config) {
println!("Erlang:");
config.erlang.as_ref().map(print_language_ids);
println!("");
println!("Gleam:");
config.gleam.as_ref().map(print_language_ids);
}

fn print_language_ids(lc: &LanguageConfig) {
for id in lc.installs.keys() {
println!("{id}")
}
}

fn get_language_config(language: &languages::Language, config: &Config) -> LanguageConfig {
match language {
languages::Language::Gleam => config.gleam.clone().unwrap_or_default(),
Expand Down
9 changes: 5 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ fn handle_command(_bin_path: PathBuf) -> Result<(), Report> {
println!("gleam");
Ok(())
}
// SubCommands::List => {
// debug!("running list");
// Ok(())
// }
SubCommands::List => {
debug!("running list");
cmd::list::run(&config);
Ok(())
}
SubCommands::Releases(ReleasesArgs { language, .. }) => {
debug!("running releases: repo={:?}", language);
// TODO: should return Result type
Expand Down

0 comments on commit 1da9b38

Please sign in to comment.