lino 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/README.md +135 -1
- data/lib/lino/version.rb +1 -1
- data/lino.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9f6cf4b79d9262b01413a60d6f0fa83bce2f831
|
4
|
+
data.tar.gz: 9f88a2482f3cb2d6bee52b173d7a59cbc2af4b76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df1cb5b66c36b08d91d0a4ef851b7c3eb527cba980347a0855b64d132f5f451a0c98b24f8bd03edb49fac4142f76a541976bb3c055115bf6bb799d8fe09059d8
|
7
|
+
data.tar.gz: b6557f3d7038e507165a5c34af7924c00ef72ad9d71693fb5d61f34b5ff66a29edc7bbcba7ec0ea257efc3d304887c8eca840c429ffa73c5ad0cb7a03c2a672f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lino (
|
4
|
+
lino (1.0.0)
|
5
5
|
hamster (~> 3.0)
|
6
6
|
open4 (~> 1.3)
|
7
7
|
|
@@ -10,6 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
concurrent-ruby (1.0.2)
|
12
12
|
diff-lcs (1.3)
|
13
|
+
gem-release (0.7.4)
|
13
14
|
hamster (3.0.0)
|
14
15
|
concurrent-ruby (~> 1.0)
|
15
16
|
open4 (1.3.4)
|
@@ -33,6 +34,7 @@ PLATFORMS
|
|
33
34
|
|
34
35
|
DEPENDENCIES
|
35
36
|
bundler (~> 1.14)
|
37
|
+
gem-release (~> 0.7)
|
36
38
|
lino!
|
37
39
|
rake (~> 10.0)
|
38
40
|
rspec (~> 3.0)
|
data/README.md
CHANGED
@@ -20,7 +20,141 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
Lino allows commands to be built and executed:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'lino'
|
27
|
+
|
28
|
+
command_line = Lino::CommandLineBuilder.for_command('ruby')
|
29
|
+
.with_flag('-v')
|
30
|
+
.with_option('-e', 'puts "Hello"')
|
31
|
+
.build
|
32
|
+
|
33
|
+
puts command_line.to_s
|
34
|
+
# => ruby -v -e puts "Hello"
|
35
|
+
|
36
|
+
command_line.execute
|
37
|
+
# ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
|
38
|
+
# Hello
|
39
|
+
```
|
40
|
+
|
41
|
+
### `Lino::CommandLineBuilder`
|
42
|
+
|
43
|
+
The `CommandLineBuilder` allows a number of different styles of commands to be built:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
# commands with flags
|
47
|
+
Lino::CommandLineBuilder.for_command('ls')
|
48
|
+
.with_flag('-l')
|
49
|
+
.with_flag('-a')
|
50
|
+
.build
|
51
|
+
.to_s
|
52
|
+
|
53
|
+
# => ls -l -a
|
54
|
+
|
55
|
+
# commands with options
|
56
|
+
Lino::CommandLineBuilder.for_command('gpg')
|
57
|
+
.with_option('--recipient', 'tobyclemson@gmail.com')
|
58
|
+
.with_option('--sign', './doc.txt')
|
59
|
+
.build
|
60
|
+
.to_s
|
61
|
+
|
62
|
+
# => gpg --recipient tobyclemson@gmail.com --sign ./doc.txt
|
63
|
+
|
64
|
+
# commands with arguments
|
65
|
+
Lino::CommandLineBuilder.for_command('diff')
|
66
|
+
.with_argument('./file1.txt')
|
67
|
+
.with_argument('./file2.txt')
|
68
|
+
.build
|
69
|
+
.to_s
|
70
|
+
|
71
|
+
# => diff ./file1.txt ./file2.txt
|
72
|
+
|
73
|
+
# commands with custom option separator
|
74
|
+
Lino::CommandLineBuilder.for_command('java')
|
75
|
+
.with_option_separator(':')
|
76
|
+
.with_option('-splash', './images/splash.jpg')
|
77
|
+
.with_argument('./application.jar')
|
78
|
+
.build
|
79
|
+
.to_s
|
80
|
+
|
81
|
+
# => java -splash:./images/splash.jpg ./application.jar
|
82
|
+
|
83
|
+
# commands using a subcommand style
|
84
|
+
Lino::CommandLineBuilder.for_command('git')
|
85
|
+
.with_flag('--no-pager')
|
86
|
+
.with_subcommand('log') do |sub|
|
87
|
+
sub.with_option('--since', '2016-01-01')
|
88
|
+
end
|
89
|
+
.build
|
90
|
+
.to_s
|
91
|
+
|
92
|
+
# => git --no-pager log --since 2016-01-01
|
93
|
+
|
94
|
+
# commands with multiple levels of subcommand
|
95
|
+
Lino::CommandLineBuilder.for_command('gcloud')
|
96
|
+
.with_subcommand('sql')
|
97
|
+
.with_subcommand('instances')
|
98
|
+
.with_subcommand('set-root-password')
|
99
|
+
.with_subcommand('some-database') do |sub|
|
100
|
+
sub.with_option('--password', 'super-secure')
|
101
|
+
end
|
102
|
+
.build
|
103
|
+
.to_s
|
104
|
+
|
105
|
+
# => gcloud sql instances set-root-password some-database --password super-secure
|
106
|
+
|
107
|
+
# commands controlled by environment variables
|
108
|
+
Lino::CommandLineBuilder.for_command('node')
|
109
|
+
.with_environment_variable('PORT', '3030')
|
110
|
+
.with_environment_variable('LOG_LEVEL', 'debug')
|
111
|
+
.with_argument('./server.js')
|
112
|
+
.build
|
113
|
+
.to_s
|
114
|
+
|
115
|
+
# => PORT=3030 LOG_LEVEL=debug node ./server.js
|
116
|
+
```
|
117
|
+
|
118
|
+
### `Lino::CommandLine`
|
119
|
+
|
120
|
+
A `CommandLine` can be executed using the `#execute` method:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
command_line = Lino::CommandLineBuilder.for_command('ls')
|
124
|
+
.with_flag('-l')
|
125
|
+
.with_flag('-a')
|
126
|
+
.with_argument('/')
|
127
|
+
.build
|
128
|
+
|
129
|
+
command_line.execute
|
130
|
+
|
131
|
+
# => <contents of / directory>
|
132
|
+
```
|
133
|
+
|
134
|
+
By default, the standard input stream is empty and the process writes to the standard output and error streams.
|
135
|
+
|
136
|
+
To populate standard input:
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
command_line.execute(stdin: 'something to be passed to standard input')
|
140
|
+
```
|
141
|
+
|
142
|
+
The `stdin` option supports any object that responds to `each`, `read` or `to_s`.
|
143
|
+
|
144
|
+
To provide custom streams for standard output or standard error:
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
require 'stringio'
|
148
|
+
|
149
|
+
stdout = StringIO.new
|
150
|
+
stderr = StringIO.new
|
151
|
+
|
152
|
+
command_line.execute(stdout: stdout, stderr: stderr)
|
153
|
+
|
154
|
+
puts "[output: #{stdout.string}, error: #{stderr.string}]"
|
155
|
+
```
|
156
|
+
|
157
|
+
The `stdout` and `stderr` options support any object that responds to `<<`.
|
24
158
|
|
25
159
|
## Development
|
26
160
|
|
data/lib/lino/version.rb
CHANGED
data/lino.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Clemson
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: gem-release
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.7'
|
83
97
|
description: Command line builders and executors.
|
84
98
|
email:
|
85
99
|
- tobyclemson@gmail.com
|