qbash 0.7.1 → 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 +9 -9
- data/README.md +7 -0
- data/lib/qbash.rb +16 -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)
|
|
@@ -100,7 +100,7 @@ GEM
|
|
|
100
100
|
parser (3.3.10.1)
|
|
101
101
|
ast (~> 2.4.1)
|
|
102
102
|
racc
|
|
103
|
-
prism (1.
|
|
103
|
+
prism (1.9.0)
|
|
104
104
|
psych (5.3.1)
|
|
105
105
|
date
|
|
106
106
|
stringio
|
|
@@ -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.
|
|
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)
|
|
@@ -124,7 +124,7 @@ GEM
|
|
|
124
124
|
parser (>= 3.3.0.2)
|
|
125
125
|
rainbow (>= 2.2.2, < 4.0)
|
|
126
126
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
127
|
-
rubocop-ast (>= 1.
|
|
127
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
128
128
|
ruby-progressbar (~> 1.7)
|
|
129
129
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
130
130
|
rubocop-ast (1.49.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,11 +110,13 @@ 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? }
|
|
119
|
+
env = env.transform_values(&:to_s)
|
|
112
120
|
cmd = cmd.reject { |a| a.nil? || (a.is_a?(String) && a.empty?) }.join(' ')
|
|
113
121
|
mtd =
|
|
114
122
|
case level
|
|
@@ -137,8 +145,13 @@ module Kernel
|
|
|
137
145
|
buf = +''
|
|
138
146
|
e = 1
|
|
139
147
|
start = Time.now
|
|
140
|
-
|
|
141
|
-
|
|
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
|
|
142
155
|
Open3.send(:popen3, *popen) do |sin, sout, serr, ctrl|
|
|
143
156
|
pid = ctrl.pid
|
|
144
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 =
|