Skip to content

Commit

Permalink
Merge pull request #32 from jay7x/gh-31
Browse files Browse the repository at this point in the history
Do not check `limactl list` exit code
  • Loading branch information
jay7x authored Jun 2, 2024
2 parents 26500cd + fbf00e6 commit 52b3633
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/cli_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,15 @@ def version

def list(vm_names = [])
lima_cmd = [@limactl, 'list', '--json'] + vm_names
stdout_str, stderr_str, status = Open3.capture3(*lima_cmd)
unless status.success?
raise LimaError, "`#{lima_cmd.join(' ')}` failed with status #{status.exitstatus}: #{stderr_str}"
end
stdout_str, _stderr_str, _status = Open3.capture3(*lima_cmd)

stdout_str.split("\n").map { |vm| JSON.parse(vm) }
end

# A bit faster `list` variant to check the VM status
def status(vm_name)
lima_cmd = [@limactl, 'list', '--format', '{{ .Status }}', vm_name]
stdout_str, stderr_str, status = Open3.capture3(*lima_cmd)
unless status.success?
raise LimaError, "`#{lima_cmd.join(' ')}` failed with status #{status.exitstatus}: #{stderr_str}"
end
stdout_str, _stderr_str, _status = Open3.capture3(*lima_cmd)

stdout_str.chomp
end
Expand Down

0 comments on commit 52b3633

Please sign in to comment.