tty-command 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01a539add505698f2073117f6df6c957e09dbeb349b6eae684eccf121d3a8a2b
4
- data.tar.gz: eae4769195fd22d266c9c76093b9f85e3b8faeb61152197d5af65e3e435dfa83
3
+ metadata.gz: bb68a910c5ff66e9272e4a13e3f2d0efd90752bcb9c4da5d6e95c338806f6041
4
+ data.tar.gz: 4d93dcafc447d2f1fb16678901b503b0a6fe73a786eb0d671743c128f687e2b4
5
5
  SHA512:
6
- metadata.gz: f3a44386dd5eb460ca3d8c7740f7c7e0660f6aeda18f0e0c7c4d67bfb30e962f4e96f34509584c5e7120d69fd415c2321b0b61d997f2f12cad101f63dfed5a93
7
- data.tar.gz: 022477365445a4da55e3ee87c4d3c23305003e6da7d7c94b6de7857e409396e4105596584ea66a7c904d7f5f5725716527e6a353391e1a97ea78928fcb1052d0
6
+ metadata.gz: '019fa8d2991d8fc81ab35b563e9538e1d992da8acbe33948d0ca45116b844f1001893f31a7613d1815bfcedb5899fbb0e4e0ae9a8030955fca67ff200056bd8f'
7
+ data.tar.gz: 3ddc25cfab6b31e2d1f18367eb92b2751068e3b1d3187c86a4169cd7e7429d7ef75d0aeaa2ff98d98eb2a95f16651bcd6417196452a2303268c254950bb898bd
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.9.0] - 2019-09-28
4
+
5
+ ### Changed
6
+ * Change gemspec to require Ruby >= 2.0.0
7
+
3
8
  ## [v0.8.2] - 2018-08-07
4
9
 
5
10
  ### Changed
@@ -123,6 +128,7 @@
123
128
 
124
129
  * Initial implementation and release
125
130
 
131
+ [v0.9.0]: https://github.com/piotrmurach/tty-command/compare/v0.8.2...v0.9.0
126
132
  [v0.8.2]: https://github.com/piotrmurach/tty-command/compare/v0.8.1...v0.8.2
127
133
  [v0.8.1]: https://github.com/piotrmurach/tty-command/compare/v0.8.0...v0.8.1
128
134
  [v0.8.0]: https://github.com/piotrmurach/tty-command/compare/v0.7.0...v0.8.0
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <div align="center">
2
+ <a href="https://piotrmurach.github.io/tty" target="_blank"><img width="130" src="https://cdn.rawgit.com/piotrmurach/tty/master/images/tty.png" alt="tty logo" /></a>
3
+ </div>
4
+
1
5
  # TTY::Command [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
2
6
 
3
7
  [![Gem Version](https://badge.fury.io/rb/tty-command.svg)][gem]
@@ -190,6 +194,8 @@ You can force the printer to always in print in color by passing the `:color` op
190
194
  cmd = TTY::Command.new(color: true)
191
195
  ```
192
196
 
197
+ If the default printers don't meet your needs you can always create [a custom printer](#34-custom-printer)
198
+
193
199
  #### 2.3.1 Color
194
200
 
195
201
  When using printers you can switch off coloring by using `:color` option set to `false`.
@@ -328,7 +334,7 @@ cmd.run(:echo, 'hello', env: {foo: 'bar', baz: nil})
328
334
 
329
335
  ### 3.2 Options
330
336
 
331
- When a hash is given in the last argument (options), it allows to specify a current directory, umask, user, group and and zero or more fd redirects for the child process.
337
+ When a hash is given in the last argument (options), it allows to specify a current directory, umask, user, group and zero or more fd redirects for the child process.
332
338
 
333
339
  #### 3.2.1 Redirection
334
340
 
@@ -415,7 +421,7 @@ cmd.run("my_cli_program", "login", in: in_stream).out
415
421
 
416
422
  #### 3.2.3 Timeout
417
423
 
418
- You can timeout command execuation by providing the `:timeout` option in seconds:
424
+ You can timeout command execution by providing the `:timeout` option in seconds:
419
425
 
420
426
  ```ruby
421
427
  cmd.run("while test 1; sleep 1; done", timeout: 5)
@@ -445,7 +451,7 @@ cmd = TTY::Command.new(binmode: true)
445
451
 
446
452
  #### 3.2.5 Signal
447
453
 
448
- You can specify process termination signal other than the defaut `SIGTERM`:
454
+ You can specify process termination signal other than the default `SIGTERM`:
449
455
 
450
456
  ```ruby
451
457
  cmd.run("whilte test1; sleep1; done", timeout: 5, signal: :KILL)
@@ -483,7 +489,7 @@ However, in `interactive` mode with `pty` flag on:
483
489
  cmd.run("git log", pty: true) # => uses pager and waits for user input (never returns)
484
490
  ```
485
491
 
486
- In addition, when pty device is used, any input to command may be echoed to the standard output, as well as some redirets may not work.
492
+ In addition, when pty device is used, any input to command may be echoed to the standard output, as well as some redirects may not work.
487
493
 
488
494
  #### 3.2.7 Current directory
489
495
 
@@ -595,22 +601,24 @@ cmd.run(:ls, '-1').each("\t") { ... }
595
601
 
596
602
  ### 3.4 Custom printer
597
603
 
598
- If the built-in printers do not meet your requirements you can create your own. At the very minimum you need to specify the `write` method that will be called during the lifecycle of command execution. The `write` accepts two arguments, first the currently run command instance and second the message to be printed:
604
+ If the built-in printers do not meet your requirements you can create your own. A printer is a regular Ruby class that can be registered through `:printer` option to receive notifications about received command data.
605
+
606
+ As the command runs the custom printer will be notified when the command starts, when data is printed to stdout, when data is printed to stderr and when the command exits.
607
+
608
+ Please see [lib/tty/command/printers/abstract.rb](https://github.com/piotrmurach/tty-command/blob/master/lib/tty/command/printers/abstract.rb) for a full set of methods that you can override.
609
+
610
+ At the very minimum you need to specify the `write` method that will be called during the lifecycle of command execution. The `write` accepts two arguments, first the currently run command instance and second the message to be printed:
599
611
 
600
612
  ```ruby
601
613
  CustomPrinter < TTY::Command::Printers::Abstract
602
614
  def write(cmd, message)
603
- puts message
615
+ puts cmd.to_command + message
604
616
  end
605
617
  end
606
618
 
607
- printer = CustomPrinter
608
-
609
- cmd = TTY::Command.new(printer: printer)
619
+ cmd = TTY::Command.new(printer: CustomPrinter)
610
620
  ```
611
621
 
612
- Please see [lib/tty/command/printers/abstract.rb](https://github.com/piotrmurach/tty-command/blob/master/lib/tty/command/printers/abstract.rb) for a full set of methods that you can override.
613
-
614
622
  ## 4. Example
615
623
 
616
624
  Here's a slightly more elaborate example to illustrate how tty-command can improve on plain old shell scripts. This example installs a new version of Ruby on an Ubuntu machine.
@@ -650,4 +658,4 @@ The gem is available as open source under the terms of the [MIT License](http://
650
658
 
651
659
  ## Copyright
652
660
 
653
- Copyright (c) 2016-2018 Piotr Murach. See LICENSE for further details.
661
+ Copyright (c) 2016 Piotr Murach. See LICENSE for further details.
@@ -0,0 +1,4 @@
1
+ require_relative "../lib/tty-command"
2
+
3
+ cmd = TTY::Command.new(pty: true)
4
+ cmd.run("rubocop")
@@ -1,3 +1 @@
1
- # encoding: utf-8
2
-
3
1
  require 'tty/command'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'tempfile'
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'securerandom'
4
4
  require 'shellwords'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require_relative 'result'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module TTY
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'thread'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module TTY
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module TTY
@@ -1,7 +1,7 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module TTY
4
4
  class Command
5
- VERSION = '0.8.2'.freeze
5
+ VERSION = '0.9.0'
6
6
  end # Command
7
7
  end # TTY
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe TTY::Command, '#run' do
2
4
  it "encodes output as unicode by default" do
3
5
  output = StringIO.new
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command::Cmd, '::new' do
4
4
  it "requires at least command argument" do
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command, 'dry run' do
4
4
  let(:output) { StringIO.new }
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command::ExitError, 'info' do
4
4
  it "displays stdin & stdout" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe TTY::Command, 'input' do
2
4
  it "reads user input data" do
3
5
  cli = fixtures_path('cli')
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'fileutils'
4
4
 
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command, ':printer' do
4
4
  it "fails to find printer for nil" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe TTY::Command, ':pty' do
2
4
  it "executes command in pseudo terminal mode as global option",
3
5
  unless: RSpec::Support::OS.windows? do
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  RSpec.describe TTY::Command, 'redirect' do
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command::Result do
4
4
  it "exits successfully" do
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command, '#ruby' do
4
4
  it "runs ruby with a single string argument" do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  RSpec.describe TTY::Command, '#run' do
4
2
  it 'runs command and prints to stdout' do
5
3
  output = StringIO.new
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command, '#test' do
4
4
  it "implements classic bash command" do
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command, '#run' do
4
4
  it "times out infinite process without input or output" do
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Command::Truncator do
4
4
  it "writes nil content" do
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'tty/command/version'
@@ -7,21 +6,25 @@ Gem::Specification.new do |spec|
7
6
  spec.name = "tty-command"
8
7
  spec.version = TTY::Command::VERSION
9
8
  spec.authors = ["Piotr Murach"]
10
- spec.email = [""]
9
+ spec.email = ["me@piotrmurach.com"]
11
10
 
12
11
  spec.summary = %q{Execute shell commands with pretty output logging and capture their stdout, stderr and exit status.}
13
12
  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
13
  spec.homepage = "https://piotrmurach.github.io/tty"
15
14
  spec.license = "MIT"
16
15
 
17
- spec.files = Dir['README.md', 'LICENSE.txt', 'CHANGELOG.md', 'Rakefile', "{lib,spec}/**/*.rb", "{bin,examples,tasks}/*", 'tty-command.gemspec']
16
+ spec.files = Dir['{lib,spec,examples}/**/*.rb']
17
+ spec.files += Dir['{bin,tasks}/*', 'tty-command.gemspec']
18
+ spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
18
19
  spec.bindir = "exe"
19
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
21
  spec.require_paths = ["lib"]
21
22
 
23
+ spec.required_ruby_version = '>= 2.0.0'
24
+
22
25
  spec.add_dependency 'pastel', '~> 0.7.0'
23
26
 
24
- spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
25
- spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'bundler', '>= 1.5.0'
28
+ spec.add_development_dependency 'rake'
26
29
  spec.add_development_dependency 'rspec', '~> 3.0'
27
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-07 00:00:00.000000000 Z
11
+ date: 2019-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pastel
@@ -31,9 +31,6 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.5.0
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '2.0'
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
@@ -41,23 +38,20 @@ dependencies:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
40
  version: 1.5.0
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '2.0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: rake
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
- - - "~>"
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: '10.0'
47
+ version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
- - - "~>"
52
+ - - ">="
59
53
  - !ruby/object:Gem::Version
60
- version: '10.0'
54
+ version: '0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: rspec
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -76,7 +70,7 @@ description: Execute shell commands with pretty output logging and capture their
76
70
  stderr and exit status. Redirect stdin, stdout and stderr of each command to a file
77
71
  or a string.
78
72
  email:
79
- - ''
73
+ - me@piotrmurach.com
80
74
  executables: []
81
75
  extensions: []
82
76
  extra_rdoc_files: []
@@ -89,7 +83,7 @@ files:
89
83
  - bin/setup
90
84
  - examples/bash.rb
91
85
  - examples/basic.rb
92
- - examples/cli
86
+ - examples/buffer.rb
93
87
  - examples/env.rb
94
88
  - examples/logger.rb
95
89
  - examples/output.rb
@@ -154,15 +148,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
154
148
  requirements:
155
149
  - - ">="
156
150
  - !ruby/object:Gem::Version
157
- version: '0'
151
+ version: 2.0.0
158
152
  required_rubygems_version: !ruby/object:Gem::Requirement
159
153
  requirements:
160
154
  - - ">="
161
155
  - !ruby/object:Gem::Version
162
156
  version: '0'
163
157
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.7.3
158
+ rubygems_version: 3.0.3
166
159
  signing_key:
167
160
  specification_version: 4
168
161
  summary: Execute shell commands with pretty output logging and capture their stdout,
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- name = $stdin.gets
4
- puts "Your name: #{name}"