Skip to content

Commit

Permalink
fix: languages command to print all languages
Browse files Browse the repository at this point in the history
Added strum as a dep to iterate over enums. less important for
languages where we have only 3 but may be more useful when it
comes to components and not leaving any of those out.
  • Loading branch information
tsloughter committed Sep 2, 2024
1 parent 18c1cee commit a7bc03c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ console = "0.15.8"
num_cpus = "1.8.0"
shell-words = "1.0.0"
octocrab = "0.38.0"
strum = { version = "0.26", features = ["derive"] }
tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] }
bytes = { version = "1.6.1", features = [] }
flate2 = "1.0.30"
Expand Down
12 changes: 9 additions & 3 deletions src/languages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::github::GithubRepo;
use crate::languages;
use clap::ValueEnum;
use color_eyre::{eyre::eyre, eyre::Result};

use strum::IntoEnumIterator;
pub mod elixir;
pub mod erlang;
pub mod gleam;
Expand Down Expand Up @@ -55,11 +55,17 @@ pub const BIN_MAP: &[(&str, languages::Language)] = &[
("mix.ps1", languages::Language::Elixir),
];

#[derive(ValueEnum, Debug, Clone, PartialEq)]
#[derive(ValueEnum, Debug, Clone, PartialEq, EnumIter)]
pub enum Language {
Elixir,
Erlang,
Gleam,
Elixir,
}

pub fn print() {
for l in Language::iter() {
println!("{:?}", l);
}
}

impl std::fmt::Display for Language {
Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ extern crate clap;

#[macro_use]
extern crate log;
#[macro_use]
extern crate strum;

use clap::{Args, Command, CommandFactory, Parser, Subcommand};
use clap_complete::{generate, Generator, Shell};
use console::style;
Expand All @@ -11,7 +14,9 @@ use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use std::process;

mod config;

use color_eyre::{eyre::eyre, eyre::Report, eyre::Result};

mod git;
Expand Down Expand Up @@ -253,8 +258,7 @@ fn handle_command(_bin_path: PathBuf) -> Result<(), Report> {
SubCommands::Languages => {
debug!("running list");
println!("Languages:\n");
println!("erlang");
println!("gleam");
languages::print();
Ok(())
}
SubCommands::List => {
Expand Down

0 comments on commit a7bc03c

Please sign in to comment.