Skip to content

Commit

Permalink
Remove filtering by language type
Browse files Browse the repository at this point in the history
This can be handled by gengo.
  • Loading branch information
spenserblack committed Apr 30, 2024
1 parent 9a1a8cd commit 7c7c29a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
10 changes: 0 additions & 10 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,6 @@ pub struct InfoCliOptions {
/// Count hidden files and directories
#[arg(long)]
pub include_hidden: bool,
/// Filters output by language type
#[arg(
long,
num_args = 1..,
default_values = &["programming", "markup"],
short = 'T',
value_enum,
)]
pub r#type: Vec<LanguageType>,
}

#[derive(Clone, Debug, Args, PartialEq, Eq)]
Expand Down Expand Up @@ -244,7 +235,6 @@ impl Default for InfoCliOptions {
no_merges: Default::default(),
email: Default::default(),
include_hidden: Default::default(),
r#type: vec![LanguageType::Programming, LanguageType::Markup],
disabled_fields: Vec::default(),
no_title: Default::default(),
}
Expand Down
8 changes: 1 addition & 7 deletions src/info/langs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ pub fn get_main_language(loc_by_language: &[(Language, usize)]) -> Language {
pub fn get_loc_by_language_sorted(
dir: &Path,
globs_to_exclude: &[String],
language_types: &[LanguageType],
include_hidden: bool,
) -> Result<Vec<(Language, usize)>> {
let stats = match get_statistics(dir, globs_to_exclude, language_types, include_hidden) {
let stats = match get_statistics(dir, globs_to_exclude, include_hidden) {
Ok(stats) => stats,
Err(e) => return Err(anyhow!("Could not analyze repository: {}", e))
};
Expand All @@ -43,15 +42,10 @@ pub fn get_total_size(loc_by_language: &[(Language, usize)]) -> usize {
fn get_statistics(
dir: &Path,
globs_to_exclude: &[String],
language_types: &[LanguageType],
include_hidden: bool,
) -> Result<gengo::Analysis, Box<dyn Error>> {
// TODO Determine best way to ignore files (and if that should continue to be handled by onefetch)
let file_source = Git::new(dir, "HEAD")?;
let gengo = Builder::new(file_source).build()?;
gengo.analyze()
}

fn filter_languages_on_type(types: &[LanguageType]) -> ! {
todo!("Determine if this is even necessary")
}
2 changes: 0 additions & 2 deletions src/info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ pub fn build_info(cli_options: &CliOptions) -> Result<Info> {

let loc_by_language_sorted_handle = std::thread::spawn({
let globs_to_exclude = cli_options.info.exclude.clone();
let language_types = cli_options.info.r#type.clone();
let include_hidden = cli_options.info.include_hidden;
let workdir = repo_path.clone();
move || {
langs::get_loc_by_language_sorted(
&workdir,
&globs_to_exclude,
&language_types,
include_hidden,
)
}
Expand Down

2 comments on commit 7c7c29a

@spenserblack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@o2sh Just confirming that this is the direction we want to go (removing these CLI options and leaving it up to gengo's config).

@o2sh
Copy link

@o2sh o2sh commented on 7c7c29a May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI option is more user-friendly, IMO (compared to editing a config file)

Please sign in to comment.