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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +20 -12
- data/examples/buffer.rb +4 -0
- data/lib/tty-command.rb +0 -2
- data/lib/tty/command/child_process.rb +0 -1
- data/lib/tty/command/cmd.rb +1 -1
- data/lib/tty/command/dry_runner.rb +0 -1
- data/lib/tty/command/exit_error.rb +0 -1
- data/lib/tty/command/process_runner.rb +0 -1
- data/lib/tty/command/result.rb +0 -1
- data/lib/tty/command/truncator.rb +0 -1
- data/lib/tty/command/version.rb +2 -2
- data/spec/unit/binmode_spec.rb +2 -0
- data/spec/unit/cmd_spec.rb +1 -1
- data/spec/unit/dry_run_spec.rb +1 -1
- data/spec/unit/exit_error_spec.rb +1 -1
- data/spec/unit/input_spec.rb +2 -0
- data/spec/unit/output_spec.rb +1 -1
- data/spec/unit/printer_spec.rb +1 -1
- data/spec/unit/pty_spec.rb +2 -0
- data/spec/unit/redirect_spec.rb +0 -1
- data/spec/unit/result_spec.rb +1 -1
- data/spec/unit/ruby_spec.rb +1 -1
- data/spec/unit/run_spec.rb +0 -2
- data/spec/unit/test_spec.rb +1 -1
- data/spec/unit/timeout_spec.rb +1 -1
- data/spec/unit/truncator_spec.rb +1 -1
- data/tty-command.gemspec +8 -5
- metadata +10 -17
- data/examples/cli +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb68a910c5ff66e9272e4a13e3f2d0efd90752bcb9c4da5d6e95c338806f6041
|
4
|
+
data.tar.gz: 4d93dcafc447d2f1fb16678901b503b0a6fe73a786eb0d671743c128f687e2b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '019fa8d2991d8fc81ab35b563e9538e1d992da8acbe33948d0ca45116b844f1001893f31a7613d1815bfcedb5899fbb0e4e0ae9a8030955fca67ff200056bd8f'
|
7
|
+
data.tar.gz: 3ddc25cfab6b31e2d1f18367eb92b2751068e3b1d3187c86a4169cd7e7429d7ef75d0aeaa2ff98d98eb2a95f16651bcd6417196452a2303268c254950bb898bd
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
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
|
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
|
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.
|
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
|
-
|
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
|
661
|
+
Copyright (c) 2016 Piotr Murach. See LICENSE for further details.
|
data/examples/buffer.rb
ADDED
data/lib/tty-command.rb
CHANGED
data/lib/tty/command/cmd.rb
CHANGED
data/lib/tty/command/result.rb
CHANGED
data/lib/tty/command/version.rb
CHANGED
data/spec/unit/binmode_spec.rb
CHANGED
data/spec/unit/cmd_spec.rb
CHANGED
data/spec/unit/dry_run_spec.rb
CHANGED
data/spec/unit/input_spec.rb
CHANGED
data/spec/unit/output_spec.rb
CHANGED
data/spec/unit/printer_spec.rb
CHANGED
data/spec/unit/pty_spec.rb
CHANGED
data/spec/unit/redirect_spec.rb
CHANGED
data/spec/unit/result_spec.rb
CHANGED
data/spec/unit/ruby_spec.rb
CHANGED
data/spec/unit/run_spec.rb
CHANGED
data/spec/unit/test_spec.rb
CHANGED
data/spec/unit/timeout_spec.rb
CHANGED
data/spec/unit/truncator_spec.rb
CHANGED
data/tty-command.gemspec
CHANGED
@@ -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['
|
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'
|
25
|
-
spec.add_development_dependency 'rake'
|
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.
|
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:
|
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: '
|
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: '
|
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/
|
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:
|
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
|
-
|
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,
|
data/examples/cli
DELETED