Class: Ace::Git::CLI::Commands::Pr
- Inherits:
-
Support::Cli::Command
- Object
- Support::Cli::Command
- Ace::Git::CLI::Commands::Pr
- Includes:
- Support::Cli::Base
- Defined in:
- lib/ace/git/cli/commands/pr.rb
Overview
ace-support-cli command for showing PR information
Instance Method Summary collapse
Instance Method Details
#call(number: nil, **options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ace/git/cli/commands/pr.rb', line 28 def call(number: nil, **) # Check if gh is installed unless Molecules::PrMetadataFetcher.gh_installed? raise Ace::Support::Cli::Error.new("GitHub CLI (gh) not installed. Install with: brew install gh") end # Determine PR identifier identifier = if number number.to_s else # Try to find PR for current branch found = Molecules::PrMetadataFetcher.find_pr_for_branch unless found raise Ace::Support::Cli::Error.new("No PR found for current branch. Specify a PR number.") end found end # Fetch PR data result = if [:with_diff] Molecules::PrMetadataFetcher.fetch_pr(identifier) else Molecules::PrMetadataFetcher.(identifier) end unless result[:success] raise Ace::Support::Cli::Error.new(result[:error]) end # Output based on format case [:format] when "json" output_data = {metadata: result[:metadata]} output_data[:diff] = result[:diff] if [:with_diff] puts JSON.pretty_generate(output_data) else output_markdown(result[:metadata], result[:diff], ) end rescue Ace::Git::Error => e raise Ace::Support::Cli::Error.new(e.) rescue ArgumentError => e raise Ace::Support::Cli::Error.new(e.) end |