Skip to content

Commit

Permalink
Merge #3414 Add versions table option to ckan show command
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Jul 29, 2021
2 parents 8c6760a + 1bc854e commit 79608b8
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 106 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
- [GUI] ru-RU translation (#3383 by: nt0g; reviewed: HebaruSan)
- [GUI] Japanese Localization (#3394 by: utah239; reviewed: HebaruSan)
- [Multiple] Match underscore in DLL to dash in identifier (#3412 by: HebaruSan; reviewed: DasSkelett)
- [CLI] Add versions table option to ckan show command (#3414 by: HebaruSan; reviewed: DasSkelett)

### Bugfixes

Expand Down
30 changes: 14 additions & 16 deletions Cmdline/Action/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public int RunCommand(CKAN.GameInstance ksp, object raw_options)
/// <returns>List of matching modules.</returns>
/// <param name="ksp">The KSP instance to perform the search for.</param>
/// <param name="term">The search term. Case insensitive.</param>
/// <param name="author">Name of author to find</param>
/// <param name="searchIncompatible">True to look for incompatible modules, false (default) to look for compatible</param>
public List<CkanModule> PerformSearch(CKAN.GameInstance ksp, string term, string author = null, bool searchIncompatible = false)
{
// Remove spaces and special characters from the search term.
Expand All @@ -134,29 +136,25 @@ public List<CkanModule> PerformSearch(CKAN.GameInstance ksp, string term, string
{
return registry
.CompatibleModules(ksp.VersionCriteria())
.Where((module) =>
{
// Look for a match in each string.
return (module.SearchableName.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableIdentifier.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableAbstract.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableDescription.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1)
&& module.SearchableAuthors.Any((auth) => auth.IndexOf(author, StringComparison.OrdinalIgnoreCase) > -1);
}).ToList();
.Where(module => (module.SearchableName.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableIdentifier.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableAbstract.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableDescription.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1)
&& module.SearchableAuthors.Any((auth) => auth.IndexOf(author, StringComparison.OrdinalIgnoreCase) > -1))
.ToList();
}
else
{
return registry
.IncompatibleModules(ksp.VersionCriteria())
.Where((module) =>
{
// Look for a match in each string.
return (module.SearchableName.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableIdentifier.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableAbstract.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableDescription.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1)
&& module.SearchableAuthors.Any((auth) => auth.IndexOf(author, StringComparison.OrdinalIgnoreCase) > -1);
}).ToList();
.Where(module => (module.SearchableName.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableIdentifier.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableAbstract.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1
|| module.SearchableDescription.IndexOf(term, StringComparison.OrdinalIgnoreCase) > -1)
&& module.SearchableAuthors.Any((auth) => auth.IndexOf(author, StringComparison.OrdinalIgnoreCase) > -1))
.ToList();
}
}

Expand Down
Loading

0 comments on commit 79608b8

Please sign in to comment.