upm 0.1.13 → 0.1.14
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/VERSION +1 -1
- data/lib/upm/lesspipe.rb +1 -1
- data/lib/upm/tool_dsl.rb +20 -21
- data/lib/upm/tools/apk.rb +10 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz: '
|
3
|
+
metadata.gz: d35aa5412644879ebc18e848569dff6bf7274e09831a5733d63ab5fedffa1916
|
4
|
+
data.tar.gz: '09b5f1c4461fea7e092cc3ce630e7586c5bd127e849e173245f4c00c9df1d79f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7837f1491c9bdfa1c08fd8a5bcad5f265bbef08d26c0bdfc2b8ee526d1ad50106b6b598edb92c7af658c8c9df6602e26ac94516a7502261a368d405e3894bfc
|
7
|
+
data.tar.gz: 35a96cabe424135bafbab8b760b4cfc2de04b4c2d9811420c004625ab9cb8aea67bbfa1108c8ddaf68d3324eea94fe808b9ce3674100779d6ba4495c61588b75
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.14
|
data/lib/upm/lesspipe.rb
CHANGED
@@ -49,7 +49,7 @@ def lesspipe(*args)
|
|
49
49
|
|
50
50
|
less_bin = File.which("less")
|
51
51
|
|
52
|
-
if File.symlink?(less_bin) and File.readlink(
|
52
|
+
if File.symlink?(less_bin) and File.readlink(less_bin)[/busybox$/]
|
53
53
|
# busybox less only supports one option!
|
54
54
|
params << "-S" unless options[:wrap] == true
|
55
55
|
else
|
data/lib/upm/tool_dsl.rb
CHANGED
@@ -2,7 +2,7 @@ module UPM
|
|
2
2
|
class Tool
|
3
3
|
module DSL
|
4
4
|
def identifying_binary(id_bin=nil)
|
5
|
-
if id_bin
|
5
|
+
if id_bin
|
6
6
|
@id_bin = id_bin
|
7
7
|
else
|
8
8
|
@id_bin || @name
|
@@ -25,7 +25,7 @@ module UPM
|
|
25
25
|
end
|
26
26
|
|
27
27
|
elsif shell_command
|
28
|
-
|
28
|
+
|
29
29
|
if shell_command.is_a? String
|
30
30
|
shell_command = shell_command.split
|
31
31
|
elsif not shell_command.is_a? Array
|
@@ -38,9 +38,9 @@ module UPM
|
|
38
38
|
end
|
39
39
|
|
40
40
|
else
|
41
|
-
|
41
|
+
|
42
42
|
raise "Error: Must supply a block or shell command"
|
43
|
-
|
43
|
+
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -50,27 +50,27 @@ module UPM
|
|
50
50
|
|
51
51
|
## Helpers
|
52
52
|
|
53
|
-
def run(*args, root: false, paged: false, grep: nil, highlight: nil)
|
53
|
+
def run(*args, root: false, paged: false, grep: nil, highlight: nil, sort: false)
|
54
54
|
if root
|
55
55
|
if Process.uid != 0
|
56
|
-
if File.which("sudo")
|
56
|
+
if File.which("sudo")
|
57
57
|
args.unshift "sudo"
|
58
58
|
elsif File.which("su")
|
59
59
|
args = ["su", "-c"] + args
|
60
60
|
else
|
61
61
|
raise "Error: You must be root to run this command. (And I couldn't find the 'sudo' *or* 'su' commands.)"
|
62
62
|
end
|
63
|
-
end
|
63
|
+
end
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
|
67
|
+
unless paged or grep or sort
|
67
68
|
system(*args)
|
68
69
|
else
|
69
|
-
|
70
70
|
IO.popen(args, err: [:child, :out]) do |command_io|
|
71
|
-
|
71
|
+
|
72
72
|
# if grep
|
73
|
-
# pattern = grep.is_a?(Regexp) ? grep.source : grep.to_s
|
73
|
+
# pattern = grep.is_a?(Regexp) ? grep.source : grep.to_s
|
74
74
|
# grep_io = IO.popen(["grep", "--color=always", "-Ei", pattern], "w+")
|
75
75
|
# IO.copy_stream(command_io, grep_io)
|
76
76
|
# grep_io.close_write
|
@@ -91,17 +91,16 @@ module UPM
|
|
91
91
|
# proc { |line| line }
|
92
92
|
# end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
lesspipe(disabled: !paged, search: highlight, always: true) do |less|
|
101
|
-
command_io.each_line do |line|
|
102
|
-
# less.puts highlight_proc.(line) if grep_proc.(line)
|
103
|
-
less.puts line if grep_proc.(line)
|
94
|
+
lesspipe(disabled: !paged, search: highlight, always: false) do |less|
|
95
|
+
each_proc = if grep
|
96
|
+
proc { |line| less.puts line if line[grep] }
|
97
|
+
else
|
98
|
+
proc { |line| less.puts line }
|
104
99
|
end
|
100
|
+
|
101
|
+
lines = command_io.each_line
|
102
|
+
lines = lines.to_a.sort if sort
|
103
|
+
lines.each(&each_proc)
|
105
104
|
end
|
106
105
|
|
107
106
|
end
|
data/lib/upm/tools/apk.rb
CHANGED
@@ -3,18 +3,22 @@ UPM::Tool.new "apk" do
|
|
3
3
|
os "alpine"
|
4
4
|
|
5
5
|
command "install", "apk add", root: true
|
6
|
+
command "remove", "apk del", root: true
|
6
7
|
command "update", "apk update", root: true
|
7
8
|
command "upgrade", "apk upgrade", root: true
|
9
|
+
command "clean", "apk clean", root: true
|
8
10
|
|
9
|
-
command "files", "apk info -L",
|
10
|
-
command "search"
|
11
|
+
command "files", "apk info -L", paged: true
|
12
|
+
command "search" do |args|
|
13
|
+
query = args.join(".+")
|
14
|
+
run "apk", "search", *args, sort: true, paged: true, highlight: query
|
15
|
+
end
|
11
16
|
|
12
|
-
command "clean", "apk clean"
|
13
|
-
|
14
17
|
command "list" do |args|
|
15
18
|
if args.any?
|
16
|
-
|
17
|
-
|
19
|
+
highlight_query = args.join(".+")
|
20
|
+
grep_query = /#{highlight_query}/
|
21
|
+
run "apk", "info", grep: grep_query, highlight: highlight_query, paged: true
|
18
22
|
else
|
19
23
|
run "apk", "info", paged: true
|
20
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- epitron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Wrap all known command-line package tools with a consistent and pretty
|
14
14
|
interface.
|