Class: SchwarmCli::HandsOffTask
- Inherits:
-
Object
- Object
- SchwarmCli::HandsOffTask
- Defined in:
- lib/schwarm_cli/hands_off_task.rb
Overview
Runs preflight checks, pushes the current branch, and creates a schwarm task pointing at it. Returns a Result the CLI command prints.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #call(prompt:, repo_override:, name_override:) ⇒ Object
-
#initialize(git: SchwarmCli::Git, client: SchwarmCli::Client.new) ⇒ HandsOffTask
constructor
A new instance of HandsOffTask.
Constructor Details
#initialize(git: SchwarmCli::Git, client: SchwarmCli::Client.new) ⇒ HandsOffTask
Returns a new instance of HandsOffTask.
10 11 12 13 |
# File 'lib/schwarm_cli/hands_off_task.rb', line 10 def initialize(git: SchwarmCli::Git, client: SchwarmCli::Client.new) @git = git @client = client end |
Instance Method Details
#call(prompt:, repo_override:, name_override:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/schwarm_cli/hands_off_task.rb', line 15 def call(prompt:, repo_override:, name_override:) repo, branch, error = run_preflight(repo_override) return error if error push_result = @git.run("push", "-u", "origin", "HEAD") return failure(push_result.stderr.strip) unless push_result.success? create_task(repo: repo, branch: branch, prompt: prompt, name_override: name_override) rescue Faraday::Error => e failure(parse_api_error(e)) end |