From e28487d5f9561e99eedf20271525ea2219b03ce2 Mon Sep 17 00:00:00 2001 From: "Tj (bougyman) Vanderpoel" Date: Fri, 2 Feb 2024 01:47:37 -0600 Subject: [PATCH] Quick rubocop cleanup --- Gemfile.lock | 2 +- lib/linear/cli/sub_commands.rb | 18 +++++++++++------- lib/linear/commands/issue/create.rb | 5 +++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b1dcf58..a7f8250 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - linear-cli (0.4.4) + linear-cli (0.4.5) base64 (~> 0.2) dry-cli (~> 1.0) dry-cli-completion (~> 1.0) diff --git a/lib/linear/cli/sub_commands.rb b/lib/linear/cli/sub_commands.rb index ba38228..eaab071 100644 --- a/lib/linear/cli/sub_commands.rb +++ b/lib/linear/cli/sub_commands.rb @@ -15,7 +15,16 @@ def const_added(const) end end - def ask_for_team # rubocop:disable Metrics/AbcSize, Metrics/MethodLength + def choose_a_team!(teams) + prompt.on(:keypress) do |event| + prompt.trigger(:keydown) if event.value == 'j' + prompt.trigger(:keyup) if event.value == 'k' + end + key = prompt.select('Choose a team', teams.to_h { |t| [t.name, t.key] }) + Rubyists::Linear::Team.find key + end + + def ask_for_team teams = Rubyists::Linear::Team.mine if teams.size == 1 logger.info('Only one team found, using it', team: teams.first.name) @@ -24,12 +33,7 @@ def ask_for_team # rubocop:disable Metrics/AbcSize, Metrics/MethodLength logger.error('No teams found for you. Please join a team or pass an existing team name.') raise SmellsBad, 'No team given and none found for you' else - prompt.on(:keypress) do |event| - prompt.trigger(:keydown) if event.value == 'j' - prompt.trigger(:keyup) if event.value == 'k' - end - key = prompt.select('Choose a team', teams.to_h { |t| [t.name, t.key] }) - Rubyists::Linear::Team.find key + choose_a_team! teams end end diff --git a/lib/linear/commands/issue/create.rb b/lib/linear/commands/issue/create.rb index 0642581..6678919 100644 --- a/lib/linear/commands/issue/create.rb +++ b/lib/linear/commands/issue/create.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'semantic_logger' +require_relative '../issue' module Rubyists # Namespace for Linear @@ -14,11 +15,11 @@ module Issue class Create include SemanticLogger::Loggable include Rubyists::Linear::CLI::CommonOptions - include Rubyists::Linear::CLI::Issue # for #gimme_da_issue and other methods + include Rubyists::Linear::CLI::Issue # for #gimme_da_issue! and other Issue methods desc 'Create a new issue' option :title, type: :string, aliases: ['-t'], desc: 'Issue Title' - option :team, type: :string, aliases: ['-T'], desc: 'Team Identifier' option :description, type: :string, aliases: ['-d'], desc: 'Issue Description' + option :team, type: :string, aliases: ['-T'], desc: 'Team Identifier' option :labels, type: :array, aliases: ['-l'], desc: 'Labels for the issue (Comma separated list)' def call(**options)