Class: Ace::Git::Molecules::GhCliExecutor
- Inherits:
-
Object
- Object
- Ace::Git::Molecules::GhCliExecutor
- Defined in:
- lib/ace/git/molecules/gh_cli_executor.rb
Overview
Safely execute gh CLI commands with timeout and structured output.
Constant Summary collapse
- DEFAULT_GH_TIMEOUT =
30- DEFAULT_SIMPLE_TIMEOUT =
10
Class Method Summary collapse
- .check_authenticated ⇒ Object
- .check_installed ⇒ Object
- .execute(subcommand, args = [], timeout: nil) ⇒ Object
Class Method Details
.check_authenticated ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/ace/git/molecules/gh_cli_executor.rb', line 30 def self.check_authenticated result = execute_simple("auth", ["status"]) raise Ace::Git::GhAuthenticationError unless result[:success] { authenticated: true, username: extract_username(result[:stderr]) } end |
.check_installed ⇒ Object
23 24 25 26 27 28 |
# File 'lib/ace/git/molecules/gh_cli_executor.rb', line 23 def self.check_installed result = execute_simple("--version") raise Ace::Git::GhNotInstalledError unless result[:success] true end |
.execute(subcommand, args = [], timeout: nil) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/ace/git/molecules/gh_cli_executor.rb', line 14 def self.execute(subcommand, args = [], timeout: nil) check_installed timeout_seconds = timeout || Ace::Git.network_timeout || DEFAULT_GH_TIMEOUT command = ["gh", subcommand] + args run_command(command, timeout_seconds) rescue Timeout::Error raise Ace::Git::TimeoutError, "gh command timed out after #{timeout_seconds} seconds" end |