tty-command 0.7.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +49 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +134 -64
  5. data/lib/tty-command.rb +1 -3
  6. data/lib/tty/command.rb +19 -18
  7. data/lib/tty/command/child_process.rb +23 -16
  8. data/lib/tty/command/cmd.rb +16 -12
  9. data/lib/tty/command/dry_runner.rb +4 -5
  10. data/lib/tty/command/exit_error.rb +1 -2
  11. data/lib/tty/command/printers/abstract.rb +11 -9
  12. data/lib/tty/command/printers/null.rb +1 -4
  13. data/lib/tty/command/printers/pretty.rb +29 -22
  14. data/lib/tty/command/printers/progress.rb +3 -8
  15. data/lib/tty/command/printers/quiet.rb +18 -8
  16. data/lib/tty/command/process_runner.rb +90 -67
  17. data/lib/tty/command/result.rb +0 -1
  18. data/lib/tty/command/truncator.rb +3 -4
  19. data/lib/tty/command/version.rb +2 -2
  20. metadata +24 -64
  21. data/.gitignore +0 -9
  22. data/.rspec +0 -4
  23. data/.travis.yml +0 -28
  24. data/CODE_OF_CONDUCT.md +0 -49
  25. data/Gemfile +0 -14
  26. data/Rakefile +0 -10
  27. data/appveyor.yml +0 -24
  28. data/benchmarks/memory.rb +0 -11
  29. data/bin/console +0 -6
  30. data/bin/setup +0 -6
  31. data/examples/bash.rb +0 -12
  32. data/examples/basic.rb +0 -9
  33. data/examples/cli +0 -4
  34. data/examples/env.rb +0 -9
  35. data/examples/logger.rb +0 -10
  36. data/examples/output.rb +0 -10
  37. data/examples/pty.rb +0 -7
  38. data/examples/redirect_stderr.rb +0 -10
  39. data/examples/redirect_stdin.rb +0 -16
  40. data/examples/redirect_stdout.rb +0 -10
  41. data/examples/stdin_input.rb +0 -10
  42. data/examples/threaded.rb +0 -12
  43. data/examples/timeout.rb +0 -7
  44. data/examples/wait.rb +0 -21
  45. data/tasks/console.rake +0 -11
  46. data/tasks/coverage.rake +0 -11
  47. data/tasks/spec.rake +0 -29
  48. data/tty-command.gemspec +0 -27
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --require spec_helper
2
- --color
3
- --format doc
4
- --warnings
@@ -1,28 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- before_install: "gem update bundler"
6
- script: "bundle exec rake ci"
7
- rvm:
8
- - 2.0.0
9
- - 2.1.10
10
- - 2.2.8
11
- - 2.3.5
12
- - 2.4.2
13
- - ruby-head
14
- - jruby-9.1.1.0
15
- - jruby-head
16
- env:
17
- global:
18
- - JRUBY_OPTS=''
19
- matrix:
20
- allow_failures:
21
- - rvm: ruby-head
22
- - rvm: jruby-head
23
- - rvm: jruby-9.1.1.0
24
- fast_finish: true
25
- branches:
26
- only: master
27
- notifications:
28
- email: false
@@ -1,49 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at [email]. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :test do
6
- gem 'simplecov', '~> 0.12.0'
7
- gem 'coveralls', '~> 0.8.17'
8
- end
9
-
10
- if RUBY_VERSION > '2.1.0'
11
- group :perf do
12
- gem 'memory_profiler', '~> 0.9.8'
13
- end
14
- end
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require "bundler/gem_tasks"
4
-
5
- FileList['tasks/**/*.rake'].each(&method(:import))
6
-
7
- task default: :spec
8
-
9
- desc 'Run all specs'
10
- task ci: %w[ spec ]
@@ -1,24 +0,0 @@
1
- ---
2
- install:
3
- - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
4
- - ruby --version
5
- - gem --version
6
- - bundle install
7
- build: off
8
- test_script:
9
- - bundle exec rake ci
10
- environment:
11
- matrix:
12
- - ruby_version: "200"
13
- - ruby_version: "200-x64"
14
- - ruby_version: "21"
15
- - ruby_version: "21-x64"
16
- - ruby_version: "22"
17
- - ruby_version: "22-x64"
18
- - ruby_version: "23"
19
- - ruby_version: "23-x64"
20
- - ruby_version: "24"
21
- - ruby_version: "24-x64"
22
- matrix:
23
- allow_failures:
24
- - ruby_version: "193"
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- require 'memory_profiler'
4
- require 'tty-command'
5
-
6
- report = MemoryProfiler.report do
7
- cmd = TTY::Command.new(color: false)
8
- cmd.run("echo 'hello world!'")
9
- end
10
-
11
- report.pretty_print(to_file: 'memory_report.txt')
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'tty-command'
5
- require 'irb'
6
- IRB.start
data/bin/setup DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
@@ -1,12 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
-
5
- cmd = TTY::Command.new
6
-
7
- f = 'file'
8
- if cmd.test("[ -f #{f} ]")
9
- puts "#{f} already exists!"
10
- else
11
- cmd.run :touch, f
12
- end
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
-
5
- cmd = TTY::Command.new
6
-
7
- out, err = cmd.run(:echo, 'hello world!')
8
-
9
- puts "Result: #{out}"
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- name = $stdin.gets
4
- puts "Your name: #{name}"
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
-
5
- cmd = TTY::Command.new
6
-
7
- out, err = cmd.run(:echo, "$FOO", env: { foo: 'hello'})
8
-
9
- puts "Result: #{out}"
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'logger'
4
- require 'tty-command'
5
-
6
- logger = Logger.new('dev.log')
7
-
8
- cmd = TTY::Command.new(output: logger, color: false)
9
-
10
- cmd.run(:ls)
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
-
5
- cmd = TTY::Command.new
6
- cmd.run("i=0; while true; do i=$[$i+1]; echo 'hello '$i; sleep 1; done") do |out, err|
7
- if out =~ /.*5.*/
8
- raise ArgumentError, 'BOOM'
9
- end
10
- end
@@ -1,7 +0,0 @@
1
- require 'tty-command'
2
-
3
- cmd = TTY::Command.new
4
-
5
- path = File.expand_path("../spec/fixtures/color", __dir__)
6
-
7
- cmd.run(path, pty: true)
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
-
5
- cmd = TTY::Command.new
6
-
7
- out, err = cmd.run("echo 'hello'", :out => :err)
8
-
9
- puts "out: #{out}"
10
- puts "err: #{err}"
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
- require 'pathname'
5
-
6
- cli = Pathname.new('examples/cli.rb')
7
- cmd = TTY::Command.new
8
-
9
- stdin = StringIO.new
10
- stdin.puts "hello"
11
- stdin.puts "world"
12
- stdin.rewind
13
-
14
- out, _ = cmd.run(cli, :in => stdin)
15
-
16
- puts "#{out}"
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
-
5
- cmd = TTY::Command.new
6
-
7
- out, err = cmd.run(:ls, :out => 'ls.log')
8
-
9
- puts "OUT>> #{out}"
10
- puts "ERR>> #{err}"
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
- require 'pathname'
5
-
6
- cmd = TTY::Command.new
7
- cli = Pathname.new('examples/cli')
8
- out, _ = cmd.run(cli, input: "Piotr\n")
9
-
10
- puts "#{out}"
@@ -1,12 +0,0 @@
1
- require 'tty-command'
2
-
3
- cmd = TTY::Command.new
4
-
5
- threads = []
6
- 3.times do |i|
7
- th = Thread.new do
8
- 10.times { cmd.run("echo th#{i}; sleep 0.1") }
9
- end
10
- threads << th
11
- end
12
- threads.each(&:join)
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
-
5
- cmd = TTY::Command.new
6
-
7
- cmd.run("while test 1; do echo 'hello'; sleep 1; done", timeout: 5, signal: :KILL)
@@ -1,21 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'tty-command'
4
- require 'logger'
5
-
6
- logger = Logger.new('dev.log')
7
- cmd = TTY::Command.new
8
-
9
- Thread.new do
10
- 10.times do |i|
11
- sleep 1
12
- if i == 5
13
- logger << "error\n"
14
- else
15
- logger << "hello #{i}\n"
16
- end
17
- end
18
- end
19
-
20
-
21
- cmd.wait('tail -f dev.log', /error/)
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Load gem inside irb console'
4
- task :console do
5
- require 'irb'
6
- require 'irb/completion'
7
- require_relative '../lib/tty-command'
8
- ARGV.clear
9
- IRB.start
10
- end
11
- task :c => :console
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Measure code coverage'
4
- task :coverage do
5
- begin
6
- original, ENV['COVERAGE'] = ENV['COVERAGE'], 'true'
7
- Rake::Task['spec'].invoke
8
- ensure
9
- ENV['COVERAGE'] = original
10
- end
11
- end
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- begin
4
- require 'rspec/core/rake_task'
5
-
6
- desc 'Run all specs'
7
- RSpec::Core::RakeTask.new(:spec) do |task|
8
- task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
9
- end
10
-
11
- namespace :spec do
12
- desc 'Run unit specs'
13
- RSpec::Core::RakeTask.new(:unit) do |task|
14
- task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
15
- end
16
-
17
- desc 'Run integration specs'
18
- RSpec::Core::RakeTask.new(:integration) do |task|
19
- task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
20
- end
21
- end
22
-
23
- rescue LoadError
24
- %w[spec spec:unit spec:integration].each do |name|
25
- task name do
26
- $stderr.puts "In order to run #{name}, do `gem install rspec`"
27
- end
28
- end
29
- end
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'tty/command/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "tty-command"
8
- spec.version = TTY::Command::VERSION
9
- spec.authors = ["Piotr Murach"]
10
- spec.email = [""]
11
-
12
- spec.summary = %q{Execute shell commands with pretty output logging and capture their stdout, stderr and exit status.}
13
- spec.description = %q{Execute shell commands with pretty output logging and capture their stdout, stderr and exit status. Redirect stdin, stdout and stderr of each command to a file or a string.}
14
- spec.homepage = "https://piotrmurach.github.io/tty"
15
- spec.license = "MIT"
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
-
22
- spec.add_dependency 'pastel', '~> 0.7.0'
23
-
24
- spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 3.0'
27
- end