mini_cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +68 -0
- data/LICENSE.txt +20 -0
- data/README.md +59 -0
- data/Rakefile +10 -0
- data/lib/mini_cli/base.rb +57 -0
- data/lib/mini_cli/version.rb +3 -0
- data/lib/mini_cli.rb +5 -0
- data/mini_cli.gemspec +29 -0
- data/spec/mini_cli/base_spec.rb +52 -0
- data/spec/mini_cli_spec.rb +7 -0
- data/spec/spec_helper.rb +17 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea711692c0f25baafc371451a02dbe2dbbe9b614
|
4
|
+
data.tar.gz: 1ebaa4205176286a479a8d9e466fb6a76240cda4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd18091197c638be75652bf314754ad35045d50b4a84501c893bddbfffe5ffc144caf24f14239586dd230b727aa632708ba60048f51f0904b62a570febf71c64
|
7
|
+
data.tar.gz: 8ede5324662a3523139ea07b98c3605de469b9df890c63facdeda59dba23fc1839f7bc04fa0360be0113b43d21d5fdf35f6c62a1c4c2c366d13d182153b4330c
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
tags
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mini_cli (0.0.1)
|
5
|
+
puma
|
6
|
+
rerun
|
7
|
+
thor (~> 0.19)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
celluloid (0.16.0)
|
13
|
+
timers (~> 4.0.0)
|
14
|
+
coderay (1.1.0)
|
15
|
+
diff-lcs (1.2.5)
|
16
|
+
ffi (1.9.6)
|
17
|
+
hitimes (1.2.2)
|
18
|
+
json (1.8.1)
|
19
|
+
listen (2.8.3)
|
20
|
+
celluloid (>= 0.15.2)
|
21
|
+
rb-fsevent (>= 0.9.3)
|
22
|
+
rb-inotify (>= 0.9)
|
23
|
+
method_source (0.8.2)
|
24
|
+
mini_check (0.2.0)
|
25
|
+
json
|
26
|
+
pry (0.10.1)
|
27
|
+
coderay (~> 1.1.0)
|
28
|
+
method_source (~> 0.8.1)
|
29
|
+
slop (~> 3.4)
|
30
|
+
puma (2.10.2)
|
31
|
+
rack (>= 1.1, < 2.0)
|
32
|
+
rack (1.5.2)
|
33
|
+
rack-test (0.6.2)
|
34
|
+
rack (>= 1.0)
|
35
|
+
rake (10.4.2)
|
36
|
+
rb-fsevent (0.9.4)
|
37
|
+
rb-inotify (0.9.5)
|
38
|
+
ffi (>= 0.5.0)
|
39
|
+
rerun (0.10.0)
|
40
|
+
listen (~> 2.7, >= 2.7.3)
|
41
|
+
rspec (3.1.0)
|
42
|
+
rspec-core (~> 3.1.0)
|
43
|
+
rspec-expectations (~> 3.1.0)
|
44
|
+
rspec-mocks (~> 3.1.0)
|
45
|
+
rspec-core (3.1.7)
|
46
|
+
rspec-support (~> 3.1.0)
|
47
|
+
rspec-expectations (3.1.2)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.1.0)
|
50
|
+
rspec-mocks (3.1.3)
|
51
|
+
rspec-support (~> 3.1.0)
|
52
|
+
rspec-support (3.1.2)
|
53
|
+
slop (3.6.0)
|
54
|
+
thor (0.19.1)
|
55
|
+
timers (4.0.1)
|
56
|
+
hitimes
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
bundler (~> 1.3)
|
63
|
+
mini_check
|
64
|
+
mini_cli!
|
65
|
+
pry
|
66
|
+
rack-test
|
67
|
+
rake
|
68
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Manuel Morales, Workshare ltd., et al.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# MiniCli
|
2
|
+
|
3
|
+
Simple command line interface for microservices built using Thor.
|
4
|
+
It provides basic commands:
|
5
|
+
|
6
|
+
```
|
7
|
+
Commands:
|
8
|
+
cli auto [COMMAND] # Re-runs the given command on any file change
|
9
|
+
cli console # Pry console with the app available
|
10
|
+
cli help [COMMAND] # Describe available commands or one specific command
|
11
|
+
cli start # Starts the Puma and any other required thread
|
12
|
+
cli test # Run the test suite
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
Inherit from MiniCli::Base to provide the basic commands:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'mini_cli'
|
22
|
+
|
23
|
+
class Cli < MiniCli::Base
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
Invoke it as a regular Thor class:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
#!/usr/bin/env ruby
|
31
|
+
|
32
|
+
require_relative 'cli'
|
33
|
+
PatioSessions::Cli.start
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Do not forget to run the tests with:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
rake
|
43
|
+
```
|
44
|
+
|
45
|
+
And bump the version with any of:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
$ gem bump --version 1.1.1 # Bump the gem version to the given version number
|
49
|
+
$ gem bump --version major # Bump the gem version to the next major level (e.g. 0.0.1 to 1.0.0)
|
50
|
+
$ gem bump --version minor # Bump the gem version to the next minor level (e.g. 0.0.1 to 0.1.0)
|
51
|
+
$ gem bump --version patch # Bump the gem version to the next patch level (e.g. 0.0.1 to 0.0.2)
|
52
|
+
```
|
53
|
+
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
Released under the MIT License.
|
58
|
+
See the [LICENSE](LICENSE.txt) file for further details.
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module MiniCli
|
4
|
+
# The base class to inherit from to provide the basic commands of a microservice
|
5
|
+
class Base < Thor
|
6
|
+
|
7
|
+
# Shows execution time to the end of the run
|
8
|
+
def self.start
|
9
|
+
require 'benchmark'
|
10
|
+
bm = Benchmark.measure { |x| super }
|
11
|
+
puts "\n#{bm.total.round(3)}s task run time"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'test', 'Run the test suite'
|
15
|
+
def test *args
|
16
|
+
args = ['spec'] if args.empty?
|
17
|
+
|
18
|
+
require 'spec/spec_helper'
|
19
|
+
|
20
|
+
RSpec::Core::Runner.run(args)
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'console', 'Pry console with the app available'
|
24
|
+
def console
|
25
|
+
require'pry'
|
26
|
+
Pry.start
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'auto [COMMAND]', 'Re-runs the given command on any file change'
|
30
|
+
long_desc 'Re-runs the given command on any file change.' +
|
31
|
+
" I. e. \"#{$0} auto test\" will run the tests on each file save."
|
32
|
+
def auto *args
|
33
|
+
require 'rerun'
|
34
|
+
|
35
|
+
options = Rerun::Options.parse [
|
36
|
+
'--background',
|
37
|
+
'--name', "./cli #{args.first}",
|
38
|
+
'--signal', 'ABRT',
|
39
|
+
]
|
40
|
+
|
41
|
+
Rerun::Runner.keep_running("./cli #{args.join " "}", options)
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'start', 'Starts the Puma and any other required thread'
|
45
|
+
def start
|
46
|
+
require 'puma/cli'
|
47
|
+
Puma::CLI.new(puma_args).run
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def puma_args
|
53
|
+
%w{-p 22000}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/lib/mini_cli.rb
ADDED
data/mini_cli.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
gem_name = "mini_cli" # TODO: Rename this
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require "#{gem_name}/version"
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = gem_name
|
10
|
+
spec.version = MiniCli::VERSION
|
11
|
+
spec.authors = ["Manuel Morales"]
|
12
|
+
spec.email = ['manuelmorales@gmail.com']
|
13
|
+
spec.description = "CLI for microservices"
|
14
|
+
spec.summary = "A Thor based CLI for services and Ruby apps."
|
15
|
+
spec.homepage = "https://github.com/manuelmorales/#{spec.name.gsub('_','-')}"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'thor', '~> 0.19'
|
24
|
+
spec.add_runtime_dependency 'rerun', '~> 0.10'
|
25
|
+
spec.add_runtime_dependency 'puma', '~> 2.10'
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
28
|
+
spec.add_development_dependency "rake", '~> 10.4'
|
29
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Base do
|
4
|
+
let(:cli){ Base.new }
|
5
|
+
|
6
|
+
describe '#test' do
|
7
|
+
it 'runs the RSpec suite' do
|
8
|
+
expect(RSpec::Core::Runner).to receive(:run)
|
9
|
+
cli.test
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'passes args to RSpec' do
|
13
|
+
expect(RSpec::Core::Runner).to receive(:run).with(['random','args'])
|
14
|
+
cli.test('random','args')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'passes ["spec"] if no args are specified' do
|
18
|
+
expect(RSpec::Core::Runner).to receive(:run).with(['spec'])
|
19
|
+
cli.test
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#console' do
|
24
|
+
it 'runs pry' do
|
25
|
+
expect(Pry).to receive(:start)
|
26
|
+
cli.console
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#start' do
|
31
|
+
before(:all){ require 'puma/cli' }
|
32
|
+
|
33
|
+
it 'runs a Puma server' do
|
34
|
+
a_puma = double('a puma')
|
35
|
+
expect(Puma::CLI).to receive(:new).with(['-p', '22000']).and_return a_puma
|
36
|
+
expect(a_puma).to receive(:run)
|
37
|
+
cli.start
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#auto' do
|
42
|
+
before(:all){ require 'rerun' }
|
43
|
+
|
44
|
+
it 'launches rerun with the given command' do
|
45
|
+
expect(Rerun::Runner).to receive(:keep_running) do |command, options|
|
46
|
+
expect(command).to eq './cli sample command'
|
47
|
+
end
|
48
|
+
cli.auto 'sample command'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.color = true
|
7
|
+
config.tty = true
|
8
|
+
# config.formatter = :documentation # :documentation, :progress, :html, :textmate
|
9
|
+
end
|
10
|
+
|
11
|
+
$LOAD_PATH.unshift File.expand_path('lib')
|
12
|
+
require 'mini_cli'
|
13
|
+
|
14
|
+
$LOAD_PATH.unshift File.expand_path('spec/support')
|
15
|
+
|
16
|
+
include MiniCli
|
17
|
+
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mini_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Manuel Morales
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.19'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.19'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rerun
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: puma
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.10'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.4'
|
83
|
+
description: CLI for microservices
|
84
|
+
email:
|
85
|
+
- manuelmorales@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/mini_cli.rb
|
97
|
+
- lib/mini_cli/base.rb
|
98
|
+
- lib/mini_cli/version.rb
|
99
|
+
- mini_cli.gemspec
|
100
|
+
- spec/mini_cli/base_spec.rb
|
101
|
+
- spec/mini_cli_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: https://github.com/manuelmorales/mini-cli
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: A Thor based CLI for services and Ruby apps.
|
127
|
+
test_files:
|
128
|
+
- spec/mini_cli/base_spec.rb
|
129
|
+
- spec/mini_cli_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
has_rdoc:
|