qbash 0.7.2 → 0.8.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 +4 -4
- data/Gemfile.lock +7 -7
- data/README.md +7 -0
- data/lib/qbash.rb +15 -3
- data/qbash.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b2a0a13831a026a1ae954bd80eaab01b20c47f2b4c07e5d05ecc4d94103b691d
|
|
4
|
+
data.tar.gz: 3207083283c1806b3840cb764b9acf70ee05cc617382c3512d4538c20164b55b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a027dfef2965ed65840633dc77252a9e83006cb2c00ab3aa89191514ef0e0a42c19f19c300ed66bd1fd65d806ba989ada97faa40017d2ae14dbad64ad8ca27c
|
|
7
|
+
data.tar.gz: 610ab8fca2dff68b7b4aabae1b5bf834acba3b1b2cc99f71c9389446a68040761c6b860a7e90ace85092b6e358ea35e54b87d967db1adabf4b72376ed65c3c4b
|
data/Gemfile.lock
CHANGED
|
@@ -34,7 +34,7 @@ GEM
|
|
|
34
34
|
multi_test (~> 1.1)
|
|
35
35
|
sys-uname (~> 1.3)
|
|
36
36
|
cucumber-ci-environment (11.0.0)
|
|
37
|
-
cucumber-core (16.
|
|
37
|
+
cucumber-core (16.2.0)
|
|
38
38
|
cucumber-gherkin (> 36, < 40)
|
|
39
39
|
cucumber-messages (> 31, < 33)
|
|
40
40
|
cucumber-tag-expressions (> 6, < 9)
|
|
@@ -49,7 +49,7 @@ GEM
|
|
|
49
49
|
date (3.5.1)
|
|
50
50
|
diff-lcs (1.6.2)
|
|
51
51
|
docile (1.4.1)
|
|
52
|
-
elapsed (0.
|
|
52
|
+
elapsed (0.3.1)
|
|
53
53
|
loog (~> 0.6)
|
|
54
54
|
tago (~> 0.1)
|
|
55
55
|
ellipsized (0.3.0)
|
|
@@ -62,11 +62,11 @@ GEM
|
|
|
62
62
|
ffi (1.17.3-x86_64-darwin)
|
|
63
63
|
ffi (1.17.3-x86_64-linux-gnu)
|
|
64
64
|
hashdiff (1.2.1)
|
|
65
|
-
json (2.18.
|
|
65
|
+
json (2.18.1)
|
|
66
66
|
language_server-protocol (3.17.0.5)
|
|
67
67
|
lint_roller (1.1.0)
|
|
68
68
|
logger (1.7.0)
|
|
69
|
-
loog (0.
|
|
69
|
+
loog (0.8.0)
|
|
70
70
|
ellipsized
|
|
71
71
|
logger (~> 1.0)
|
|
72
72
|
memoist3 (1.0.0)
|
|
@@ -108,15 +108,15 @@ GEM
|
|
|
108
108
|
racc (1.8.1)
|
|
109
109
|
rainbow (3.1.1)
|
|
110
110
|
rake (13.3.1)
|
|
111
|
-
random-port (0.
|
|
111
|
+
random-port (0.8.2)
|
|
112
112
|
tago (~> 0.0)
|
|
113
|
-
rdoc (7.
|
|
113
|
+
rdoc (7.2.0)
|
|
114
114
|
erb
|
|
115
115
|
psych (>= 4.0.0)
|
|
116
116
|
tsort
|
|
117
117
|
regexp_parser (2.11.3)
|
|
118
118
|
rexml (3.4.4)
|
|
119
|
-
rubocop (1.84.
|
|
119
|
+
rubocop (1.84.2)
|
|
120
120
|
json (~> 2.3)
|
|
121
121
|
language_server-protocol (~> 3.17.0.2)
|
|
122
122
|
lint_roller (~> 1.1.0)
|
data/README.md
CHANGED
|
@@ -128,6 +128,13 @@ end
|
|
|
128
128
|
This raises a `Timeout::Error` exception after five seconds
|
|
129
129
|
of waiting for `sleep` to finish.
|
|
130
130
|
|
|
131
|
+
By default, `qbash` runs commands through `/bin/bash`.
|
|
132
|
+
To run commands through the system shell instead (useful on Windows), use:
|
|
133
|
+
|
|
134
|
+
```ruby
|
|
135
|
+
qbash('dir C:\\', raw: true)
|
|
136
|
+
```
|
|
137
|
+
|
|
131
138
|
## How to contribute
|
|
132
139
|
|
|
133
140
|
Read [these guidelines][guidelines].
|
data/lib/qbash.rb
CHANGED
|
@@ -75,6 +75,12 @@ module Kernel
|
|
|
75
75
|
# # Useful for commands that operate on the current directory
|
|
76
76
|
# qbash('git status', chdir: '/path/to/repo')
|
|
77
77
|
#
|
|
78
|
+
# == Raw Mode (System Shell)
|
|
79
|
+
#
|
|
80
|
+
# # Run command through the system shell instead of /bin/bash
|
|
81
|
+
# # Useful on Windows where /bin/bash is not available
|
|
82
|
+
# qbash('dir C:\\', raw: true)
|
|
83
|
+
#
|
|
78
84
|
# For command with multiple arguments, you can use +Shellwords.escape()+ to
|
|
79
85
|
# properly escape each argument.
|
|
80
86
|
#
|
|
@@ -104,9 +110,10 @@ module Kernel
|
|
|
104
110
|
# @param [Boolean] both If set to TRUE, the function returns an array +(stdout, code)+
|
|
105
111
|
# @param [Integer] level Logging level (use +Logger::DEBUG+, +Logger::INFO+, +Logger::WARN+, or +Logger::ERROR+)
|
|
106
112
|
# @param [String] chdir Directory to change to before running the command (or +nil+ to use current directory)
|
|
113
|
+
# @param [Boolean] raw If +true+, run the command via the system shell instead of +/bin/bash+
|
|
107
114
|
# @return [String] Everything that was printed to the +stdout+ by the command
|
|
108
115
|
def qbash(*cmd, opts: [], stdin: '', env: {}, stdout: Loog::NULL, stderr: nil, accept: [0], both: false,
|
|
109
|
-
level: Logger::DEBUG, chdir: nil)
|
|
116
|
+
level: Logger::DEBUG, chdir: nil, raw: false)
|
|
110
117
|
stderr ||= stdout
|
|
111
118
|
env.each { |k, v| raise "env[#{k}] is nil" if v.nil? }
|
|
112
119
|
env = env.transform_values(&:to_s)
|
|
@@ -138,8 +145,13 @@ module Kernel
|
|
|
138
145
|
buf = +''
|
|
139
146
|
e = 1
|
|
140
147
|
start = Time.now
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
popen =
|
|
149
|
+
if raw
|
|
150
|
+
chdir.nil? ? [env, cmd] : [env, cmd, { chdir: }]
|
|
151
|
+
else
|
|
152
|
+
bash = ['/bin/bash'] + opts + ['-c', cmd]
|
|
153
|
+
chdir.nil? ? [env, *bash] : [env, *bash, { chdir: }]
|
|
154
|
+
end
|
|
143
155
|
Open3.send(:popen3, *popen) do |sin, sout, serr, ctrl|
|
|
144
156
|
pid = ctrl.pid
|
|
145
157
|
printer[stderr, "+ #{cmd} /##{pid}"]
|
data/qbash.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
10
10
|
s.required_ruby_version = '>=3.2'
|
|
11
11
|
s.name = 'qbash'
|
|
12
|
-
s.version = '0.
|
|
12
|
+
s.version = '0.8.0'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
s.summary = 'Quick Executor of a BASH Command'
|
|
15
15
|
s.description =
|