aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leap_cli/util.rb')
-rw-r--r--lib/leap_cli/util.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb
index 967acca..98c3002 100644
--- a/lib/leap_cli/util.rb
+++ b/lib/leap_cli/util.rb
@@ -2,6 +2,7 @@ require 'digest/md5'
require 'paint'
require 'fileutils'
require 'erb'
+require 'pty'
module LeapCli
module Util
@@ -84,9 +85,10 @@ module LeapCli
def assert_files_missing!(*files)
options = files.last.is_a?(Hash) ? files.pop : {}
+ base = options[:base] || Path.provider
file_list = files.collect { |file_path|
- file_path = Path.named_path(file_path)
- File.exists?(file_path) ? Path.relative_path(file_path) : nil
+ file_path = Path.named_path(file_path, base)
+ File.exists?(file_path) ? Path.relative_path(file_path, base) : nil
}.compact
if file_list.length > 1
bail! do
@@ -280,6 +282,21 @@ module LeapCli
STDOUT.puts
end
+ #
+ # runs a command in a pseudo terminal
+ #
+ def pty_run(cmd)
+ PTY.spawn(cmd) do |output, input, pid|
+ begin
+ while line = output.gets do
+ puts line
+ end
+ rescue Errno::EIO
+ end
+ end
+ rescue PTY::ChildExited
+ end
+
##
## ERB
##