-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add --project filter * WIP support methods for filtering issue list by Project * Allow projects to be found with ID or URL as well * move project finder methods to separate module * Use the new common project finder methods in CLI::Projects * Appease the cyclic complexity gods * tests around Project#match_score? * Need to include CLI::SubCommands here to get #prompt support * improve comment * Abstract #project_for so it can be used in both Listing Issues and Creating Issues * removed by rubocop * prefer #fetch so we know if we try to query on a nonexistant key * remove the safe-nav operator that could end up doing the exact opposite of what I want * chore: Remove Gemfile.lock * fix(linting): Corrects rubocop offenses --------- Co-authored-by: Tj (bougyman) Vanderpoel <[email protected]>
- Loading branch information
Showing
10 changed files
with
121 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ | |
# dotenv | ||
.envrc | ||
|
||
# built gems | ||
# Gem stuff/Gemfile.lock | ||
*.gem | ||
Gemfile.lock |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Rubyists | ||
module Linear | ||
module CLI | ||
# The Project module contains support for finding and selecting projects | ||
# as part of a filter or query | ||
module Projects | ||
def ask_for_projects(projects, search: true) | ||
prompt.warn("No project found matching #{search}.") if search | ||
return projects.first if projects.size == 1 | ||
|
||
prompt.select('Project:', projects.to_h { |p| [p.name, p] }) | ||
end | ||
|
||
def project_scores(projects, search_term) | ||
projects.select { |p| p.match_score?(search_term).positive? }.sort_by { |p| p.match_score?(search_term) } | ||
end | ||
|
||
def project_for(project = nil, projects: Project.all) | ||
return nil if projects.empty? | ||
|
||
possibles = project ? project_scores(projects, project) : [] | ||
return ask_for_projects(projects, search: project) if possibles.empty? | ||
|
||
first = possibles.first | ||
return first if first.match_score?(project) == 100 | ||
|
||
selections = possibles + (projects - possibles) | ||
prompt.select('Project:', selections.to_h { |p| [p.name, p] }) if possibles.size.positive? | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.