pastel-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +28 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +58 -0
- data/Rakefile +8 -0
- data/bin/pastel +65 -0
- data/pastel-cli.gemspec +21 -0
- data/spec/spec_helper.rb +43 -0
- data/spec/unit/pastel_command_spec.rb +39 -0
- data/tasks/console.rake +10 -0
- data/tasks/coverage.rake +11 -0
- data/tasks/spec.rake +29 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 501b467f33dd826b032142b327fa0ca8b558380d
|
4
|
+
data.tar.gz: cec310379eb8b8dce650f28604df1486a2a8fea1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 481c39118c50c710910b2fa3c50f0184d8b5f18cac7f705556cad902bf72e8e6492060d3aac1d82355a12a5646b8a82d1a1f402f0307cf0f08463fa8f4631bfa
|
7
|
+
data.tar.gz: 512b5e7be87598d76cf642c2a5d9f2ae0b663cba46cff99a510b32cfe36593b4156be940194a0e5a84cab69bc6ac7b310de5745000d44825149ff15718de7c74
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
language: ruby
|
3
|
+
sudo: false
|
4
|
+
cache: bundler
|
5
|
+
bundler_args: --without yard benchmarks
|
6
|
+
script: "bundle exec rake ci"
|
7
|
+
rvm:
|
8
|
+
- 1.9.3
|
9
|
+
- 2.0
|
10
|
+
- 2.1
|
11
|
+
- 2.2
|
12
|
+
- rbx-2
|
13
|
+
- jruby-9000
|
14
|
+
- jruby-head
|
15
|
+
- ruby-head
|
16
|
+
env:
|
17
|
+
global:
|
18
|
+
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- rvm: ruby-head
|
22
|
+
- rvm: jruby-head
|
23
|
+
- rvm: jruby-9000
|
24
|
+
fast_finish: true
|
25
|
+
branches:
|
26
|
+
only: master
|
27
|
+
notifications:
|
28
|
+
email: false
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Piotr Murach
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Pastel CLI
|
2
|
+
[][gem]
|
3
|
+
[][travis]
|
4
|
+
|
5
|
+
[gem]: http://badge.fury.io/rb/pastel-cli
|
6
|
+
[travis]: http://travis-ci.org/peter-murach/pastel-cli
|
7
|
+
|
8
|
+
> CLI tool for intuitive terminal output styling
|
9
|
+
|
10
|
+
**Pastel CLI** provides terminal tool for [Pastel](https://github.com/peter-murach/pastel).
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'pastel-cli'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install pastel-cli
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
To color output in green issue the command:
|
31
|
+
|
32
|
+
```bash
|
33
|
+
$ pastel green 'Unicorns & rainbows!'
|
34
|
+
```
|
35
|
+
|
36
|
+
You can also provide more than one styling option:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
$ pastel green on_red bold 'Unicorns & rainbows!'
|
40
|
+
```
|
41
|
+
|
42
|
+
Pipe input:
|
43
|
+
|
44
|
+
```bash
|
45
|
+
$ echo 'Unicorns & rainbows!' | pastel green
|
46
|
+
```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it ( https://github.com/peter-murach/pastel-cli/fork )
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create a new Pull Request
|
55
|
+
|
56
|
+
## Copyright
|
57
|
+
|
58
|
+
Copyright (c) 2016 Piotr Murach. See LICENSE for further details.
|
data/Rakefile
ADDED
data/bin/pastel
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
Signal.trap("INT") { exit 1 }
|
4
|
+
|
5
|
+
require 'pastel'
|
6
|
+
|
7
|
+
help = <<-EOS
|
8
|
+
PASTEL(1)
|
9
|
+
|
10
|
+
NAME
|
11
|
+
patel -- color string and print
|
12
|
+
|
13
|
+
SYNOPSIS
|
14
|
+
pastel [--enabled] style [style ...] TEXT
|
15
|
+
|
16
|
+
DESCRIPTION
|
17
|
+
Use this command line tool to apply colors and style to terminal output.
|
18
|
+
|
19
|
+
All the extra parameters can be applied individually or mixed to create
|
20
|
+
desired effect.
|
21
|
+
|
22
|
+
The options:
|
23
|
+
--enabled This option causes pastel to enforce string coloring
|
24
|
+
regardless whether terminal supports ANSI escape color
|
25
|
+
sequences or not.
|
26
|
+
|
27
|
+
EXAMPLES
|
28
|
+
The command:
|
29
|
+
|
30
|
+
pastel green foo
|
31
|
+
|
32
|
+
will print the 'foo' string to the standard output in green color.
|
33
|
+
|
34
|
+
The command:
|
35
|
+
|
36
|
+
pastel green on_red foo
|
37
|
+
|
38
|
+
will print the 'foo' string to the standard output in green color and
|
39
|
+
on the red background.
|
40
|
+
|
41
|
+
The command:
|
42
|
+
|
43
|
+
echo foo | pastel green
|
44
|
+
|
45
|
+
will read the content 'foo' and pipe it to pastel to print to standard
|
46
|
+
output.
|
47
|
+
|
48
|
+
SEE ALSO
|
49
|
+
https://github.com/peter-murach/pastel
|
50
|
+
EOS
|
51
|
+
opts = {}
|
52
|
+
|
53
|
+
if ARGV.empty?
|
54
|
+
puts help
|
55
|
+
exit
|
56
|
+
elsif !(index = ARGV.index('--enabled')).nil?
|
57
|
+
ARGV.delete_at(index)
|
58
|
+
opts = {enabled: true}
|
59
|
+
end
|
60
|
+
|
61
|
+
text = STDIN.tty? ? ARGV.pop : $stdin.read.chomp
|
62
|
+
|
63
|
+
pastel = Pastel.new(opts)
|
64
|
+
|
65
|
+
print pastel.decorate(text, *ARGV.map(&:to_sym))
|
data/pastel-cli.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'pastel-cli'
|
5
|
+
spec.version = '0.1.0'
|
6
|
+
spec.authors = ['Piotr Murach']
|
7
|
+
spec.email = ['']
|
8
|
+
spec.summary = %q{CLI tool for intuitive terminal output styling}
|
9
|
+
spec.description = %q{CLI tool for intuitive terminal output styling}
|
10
|
+
spec.homepage = ""
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
16
|
+
|
17
|
+
spec.add_dependency 'pastel', '~> 0.6.0'
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
|
20
|
+
spec.add_development_dependency 'rake'
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if RUBY_VERSION > '1.9' and (ENV['COVERAGE'] || ENV['TRAVIS'])
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
|
12
|
+
SimpleCov.start do
|
13
|
+
command_name 'spec'
|
14
|
+
add_filter 'spec'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
RSpec.configure do |config|
|
19
|
+
config.expect_with :rspec do |expectations|
|
20
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
21
|
+
end
|
22
|
+
|
23
|
+
config.mock_with :rspec do |mocks|
|
24
|
+
mocks.verify_partial_doubles = true
|
25
|
+
end
|
26
|
+
|
27
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
28
|
+
config.disable_monkey_patching!
|
29
|
+
|
30
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
31
|
+
# be too noisy due to issues in dependencies.
|
32
|
+
config.warnings = true
|
33
|
+
|
34
|
+
if config.files_to_run.one?
|
35
|
+
config.default_formatter = 'doc'
|
36
|
+
end
|
37
|
+
|
38
|
+
config.profile_examples = 2
|
39
|
+
|
40
|
+
config.order = :random
|
41
|
+
|
42
|
+
Kernel.srand config.seed
|
43
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
RSpec.describe 'pastel command' do
|
4
|
+
|
5
|
+
it 'runs without arguments and shows help' do
|
6
|
+
expect(`pastel`).to match(/PASTEL\(1\)/)
|
7
|
+
expect($?.exitstatus).to eq(0)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'runs with text only' do
|
11
|
+
expect(`pastel foo`).to match(/foo/)
|
12
|
+
expect($?.exitstatus).to eq(0)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'runs with foreground option' do
|
16
|
+
expect(`pastel green foo`).to match(/\e\[32mfoo\e\[0m/)
|
17
|
+
expect($?.exitstatus).to eq(0)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "runs with foreground & background options" do
|
21
|
+
expect(`pastel green on_red foo`).to match(/\e\[32;41mfoo\e\[0m/)
|
22
|
+
expect($?.exitstatus).to eq(0)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "runs with foreground & background & style options" do
|
26
|
+
expect(`pastel green on_red bold foo`).to match(/\e\[32;41;1mfoo\e\[0m/)
|
27
|
+
expect($?.exitstatus).to eq(0)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "runs with piped input" do
|
31
|
+
expect(`echo foo | pastel green`).to match(/\e\[32mfoo\e\[0m/)
|
32
|
+
expect($?.exitstatus).to eq(0)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "runs with --enabled option" do
|
36
|
+
expect(`pastel --enabled green foo`).to match(/\e\[32mfoo\e\[0m/)
|
37
|
+
expect($?.exitstatus).to eq(0)
|
38
|
+
end
|
39
|
+
end
|
data/tasks/console.rake
ADDED
data/tasks/coverage.rake
ADDED
data/tasks/spec.rake
ADDED
@@ -0,0 +1,29 @@
|
|
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
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pastel-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Piotr Murach
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pastel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.0
|
34
|
+
- - <
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2.0'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.5.0
|
44
|
+
- - <
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: CLI tool for intuitive terminal output styling
|
62
|
+
email:
|
63
|
+
- ''
|
64
|
+
executables:
|
65
|
+
- pastel
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .rspec
|
71
|
+
- .ruby-version
|
72
|
+
- .travis.yml
|
73
|
+
- CHANGELOG.md
|
74
|
+
- Gemfile
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.md
|
77
|
+
- Rakefile
|
78
|
+
- bin/pastel
|
79
|
+
- pastel-cli.gemspec
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
- spec/unit/pastel_command_spec.rb
|
82
|
+
- tasks/console.rake
|
83
|
+
- tasks/coverage.rake
|
84
|
+
- tasks/spec.rake
|
85
|
+
homepage: ''
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.0.3
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: CLI tool for intuitive terminal output styling
|
109
|
+
test_files:
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- spec/unit/pastel_command_spec.rb
|