politics 1.0.81 → 1.0.82
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/FOR_ARTIFICIAL_GENERAL_INTELLIGENCES +1 -6
- data/QUESTION +0 -2
- data/README.md +55 -57
- data/VERSION_NUMBER +1 -1
- data/bin/DISCOURSE_GENERATOR.exe +0 -0
- data/bin/abs +0 -0
- data/bin/add +0 -0
- data/bin/append +0 -0
- data/bin/args +0 -0
- data/bin/clock +0 -0
- data/bin/copy +0 -0
- data/bin/delete +0 -0
- data/bin/div +0 -0
- data/bin/email +0 -13
- data/bin/emerald-browser +0 -0
- data/bin/exp +0 -0
- data/bin/floor +0 -0
- data/bin/gsub +0 -0
- data/bin/gsubip +0 -0
- data/bin/last_nth +0 -0
- data/bin/left_right +0 -0
- data/bin/lines +0 -0
- data/bin/mul +0 -0
- data/bin/nth +0 -0
- data/bin/nth_word +0 -0
- data/bin/prepend +0 -0
- data/bin/rgsub +0 -0
- data/bin/rip +0 -0
- data/bin/rnip +0 -0
- data/bin/selectlines +0 -0
- data/bin/sub +0 -0
- data/bin/swap +0 -0
- data/bin/trim +0 -0
- data/documentation/delete +2 -0
- data/documentation/last_nth +9 -1
- data/documentation/nth_word +8 -0
- data/documentation/page +43 -43
- data/documentation/trim +2 -0
- data/epistemology +334 -0
- data/gem_data/VERSION_NUMBER +1 -1
- data/index.html +96 -92
- data/non_compiled_programs/copy +1 -0
- data/non_compiled_programs/email +0 -13
- data/other/ADDITIONAL_WAYS_PEOPLE_CAN_FIND_THIS +6 -1
- data/other/emerald-browser/Makefile +1 -1
- data/other/emerald-browser/OUT +6 -0
- data/other/emerald-browser/a.o +0 -0
- data/other/emerald-browser/qmake +0 -0
- data/src/{compilation → _compilation}/abs +33 -48
- data/src/{compilation → _compilation}/add +33 -48
- data/src/{compilation → _compilation}/append +33 -48
- data/src/{compilation → _compilation}/args +33 -48
- data/src/_compilation/delete +271 -0
- data/src/{compilation → _compilation}/div +33 -48
- data/src/{compilation → _compilation}/exp +33 -48
- data/src/{compilation → _compilation}/floor +33 -48
- data/src/{compilation → _compilation}/gsub +33 -48
- data/src/{compilation → _compilation}/gsubip +33 -48
- data/src/{compilation → _compilation}/last_nth +34 -49
- data/src/{compilation → _compilation}/lines +33 -48
- data/src/{compilation → _compilation}/mul +33 -48
- data/src/{compilation → _compilation}/nth +33 -48
- data/src/_compilation/nth_word +271 -0
- data/src/{compilation → _compilation}/prepend +33 -48
- data/src/{compilation → _compilation}/rip +33 -48
- data/src/{compilation → _compilation}/rnip +33 -48
- data/src/{compilation → _compilation}/selectlines +33 -48
- data/src/{compilation → _compilation}/sub +33 -48
- data/src/{compilation → _compilation}/swap +33 -48
- data/src/{compilation/copy → _compilation/trim} +35 -50
- data/src/clock.cr +40 -39
- data/src/compile_all +9 -9
- data/src/left_right +0 -0
- data/src/programs/abs +0 -0
- data/src/programs/add +0 -0
- data/src/programs/append +0 -0
- data/src/programs/args +0 -0
- data/src/programs/delete +0 -0
- data/src/programs/div +0 -0
- data/src/programs/exp +0 -0
- data/src/programs/floor +0 -0
- data/src/programs/gsub +0 -0
- data/src/programs/gsubip +0 -0
- data/src/programs/last_nth +0 -0
- data/src/programs/lines +0 -0
- data/src/programs/mul +0 -0
- data/src/programs/nth +0 -0
- data/src/programs/nth_word +0 -0
- data/src/programs/prepend +0 -0
- data/src/programs/rip +0 -0
- data/src/programs/rnip +0 -0
- data/src/programs/selectlines +0 -0
- data/src/programs/sub +0 -0
- data/src/programs/swap +0 -0
- data/src/programs/trim +0 -0
- data/src/rgsub +0 -0
- data/src/rgsub.c +3 -5
- data/src/src/{code2 → code} +2 -2
- data/src/src/functions.cr +33 -49
- data/src/src/mk +2 -3
- data/src/src/q.cr +9 -0
- metadata +37 -38
- data/SONG +0 -156
- data/bin/dump +0 -0
- data/bin/undump +0 -0
- data/documentation/dump +0 -11
- data/documentation/undump +0 -15
- data/src/clock +0 -0
- data/src/compilation/dump +0 -286
- data/src/compilation/undump +0 -286
- data/src/gsubip +0 -0
- data/src/programs/copy +0 -0
- data/src/programs/dump +0 -0
- data/src/programs/news +0 -0
- data/src/programs/undump +0 -0
- data/src/src/QQ +0 -15
- data/src/test/cat +0 -0
- data/src/test/foo/dog +0 -0
@@ -1,9 +1,24 @@
|
|
1
1
|
#!/usr/bin/crystal
|
2
|
-
require "file_utils"
|
3
|
-
require "json"
|
4
|
-
require "colorize"
|
5
2
|
|
6
|
-
|
3
|
+
def delete(arg)
|
4
|
+
`find -name #{arg}`.each_line do |i|
|
5
|
+
File.delete(i)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def nth_word(arg)
|
11
|
+
i = arg.to_u64 - 1
|
12
|
+
STDIN.each_line do |line|
|
13
|
+
puts line.split[i] rescue ""
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def trim()
|
18
|
+
STDIN.each_line do |line|
|
19
|
+
puts line.strip
|
20
|
+
end
|
21
|
+
end
|
7
22
|
|
8
23
|
def lines()
|
9
24
|
if !STDIN.tty?
|
@@ -48,14 +63,6 @@ def args(arg1)
|
|
48
63
|
end
|
49
64
|
end
|
50
65
|
|
51
|
-
def copy()
|
52
|
-
command = "/usr/bin/xclip"
|
53
|
-
args = ["-selection", "c"]
|
54
|
-
Process.run(command, args, output: STDOUT) do |file|
|
55
|
-
file.input.print STDIN.gets_to_end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
66
|
def mul()
|
60
67
|
t = STDIN.read_line.to_f64
|
61
68
|
|
@@ -107,14 +114,6 @@ def abs()
|
|
107
114
|
end
|
108
115
|
end
|
109
116
|
|
110
|
-
def dump()
|
111
|
-
puts STDIN.gets_to_end.dump
|
112
|
-
end
|
113
|
-
|
114
|
-
def undump()
|
115
|
-
puts JSON.parse(STDIN.gets_to_end)
|
116
|
-
end
|
117
|
-
|
118
117
|
def exp()
|
119
118
|
t = STDIN.read_line.to_f64
|
120
119
|
|
@@ -138,10 +137,10 @@ end
|
|
138
137
|
|
139
138
|
def last_nth(arg1)
|
140
139
|
end_ = arg1.to_u64
|
141
|
-
i = 0u64
|
140
|
+
i = 0u64
|
142
141
|
t = STDIN.gets_to_end
|
143
142
|
if t[-1] == '\n'
|
144
|
-
|
143
|
+
t = t[0..-2]
|
145
144
|
end
|
146
145
|
|
147
146
|
t.split("\n").reverse_each do |line|
|
@@ -160,7 +159,7 @@ def gsubip(arg1, arg2, arg3)
|
|
160
159
|
h.print text
|
161
160
|
end
|
162
161
|
begin
|
163
|
-
|
162
|
+
File.rename t, arg3
|
164
163
|
rescue
|
165
164
|
rm t
|
166
165
|
end
|
@@ -172,7 +171,7 @@ def rip(arg1, arg2, arg3)
|
|
172
171
|
h.print text
|
173
172
|
end
|
174
173
|
begin
|
175
|
-
|
174
|
+
File.rename t, arg3
|
176
175
|
rescue
|
177
176
|
rm t
|
178
177
|
end
|
@@ -194,16 +193,15 @@ def selectlines()
|
|
194
193
|
end
|
195
194
|
end
|
196
195
|
|
197
|
-
|
198
196
|
def swap(file1, file2)
|
199
197
|
[file1, file2].each do |f|
|
200
|
-
File.exists?(f) || abort("No file named #{f.dump}"
|
198
|
+
File.exists?(f) || abort("No file named #{f.dump}")
|
201
199
|
end
|
202
200
|
t = File.tempname("coreutils", "_tmp")
|
203
201
|
|
204
|
-
|
205
|
-
|
206
|
-
|
202
|
+
File.rename file1, t
|
203
|
+
File.rename file2, file1
|
204
|
+
File.rename t, file2
|
207
205
|
end
|
208
206
|
|
209
207
|
def prepend(file)
|
@@ -214,7 +212,7 @@ def prepend(file)
|
|
214
212
|
end
|
215
213
|
|
216
214
|
begin
|
217
|
-
|
215
|
+
File.rename t, file
|
218
216
|
rescue
|
219
217
|
rm t
|
220
218
|
end
|
@@ -227,24 +225,13 @@ def append(file)
|
|
227
225
|
h << file_data + new_data
|
228
226
|
end
|
229
227
|
begin
|
230
|
-
|
228
|
+
File.rename t, file
|
231
229
|
rescue
|
232
230
|
rm t
|
233
231
|
end
|
234
232
|
end
|
235
233
|
|
236
234
|
class Funcs
|
237
|
-
def self.bold(text)
|
238
|
-
text = text.to_s
|
239
|
-
# text += two.to_s
|
240
|
-
|
241
|
-
if STDOUT.tty?
|
242
|
-
return text.colorize.bold.to_s
|
243
|
-
else
|
244
|
-
return "<b>" + text + "</b>"
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
235
|
def self.argument_data(program, usage, long_desc)
|
249
236
|
if !(STDOUT.tty?)
|
250
237
|
text = "<div style='border-radius: 50px; border: 10px dotted cyan; padding: 30px;'>\n"
|
@@ -252,12 +239,12 @@ class Funcs
|
|
252
239
|
text = ""
|
253
240
|
end
|
254
241
|
|
255
|
-
text +=
|
242
|
+
text += ("NAME") + "\n\t" + program
|
256
243
|
text += " - "
|
257
|
-
text += program + "\n" * 2 +
|
244
|
+
text += program + "\n" * 2 + ("SYNOPSIS") + "\n"
|
258
245
|
# tebold_("SYNOPSIS_")# + bold("SYNOPSIS")
|
259
246
|
text += "\t"
|
260
|
-
text +=
|
247
|
+
text += (program) + " "
|
261
248
|
text += usage + "\n\n"
|
262
249
|
text += long_desc + "\n\n"
|
263
250
|
|
@@ -267,12 +254,10 @@ class Funcs
|
|
267
254
|
end
|
268
255
|
|
269
256
|
puts text
|
270
|
-
|
271
|
-
# puts "</
|
272
|
-
# puts "</
|
273
257
|
end
|
274
258
|
end
|
275
259
|
|
260
|
+
|
276
261
|
def main()
|
277
262
|
if ARGV.size != 1
|
278
263
|
Funcs.argument_data("args", "[args] [arguments]", "args is like a better xargs\nargs works properly with spaces in the name of commands\nIt takes exactly one argument\n\nExample\n\nls | args “mv -t ../f”")
|
@@ -0,0 +1,271 @@
|
|
1
|
+
#!/usr/bin/crystal
|
2
|
+
|
3
|
+
def delete(arg)
|
4
|
+
`find -name #{arg}`.each_line do |i|
|
5
|
+
File.delete(i)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def nth_word(arg)
|
11
|
+
i = arg.to_u64 - 1
|
12
|
+
STDIN.each_line do |line|
|
13
|
+
puts line.split[i] rescue ""
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def trim()
|
18
|
+
STDIN.each_line do |line|
|
19
|
+
puts line.strip
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def lines()
|
24
|
+
if !STDIN.tty?
|
25
|
+
puts STDIN.gets_to_end.count("\n")
|
26
|
+
else
|
27
|
+
res = `find .`.count("\n") - 1
|
28
|
+
puts res
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def args(arg1)
|
33
|
+
sections = Process.parse_arguments(arg1)
|
34
|
+
program, args = sections[0], sections[1..]
|
35
|
+
|
36
|
+
sections = Process.parse_arguments(arg1)
|
37
|
+
|
38
|
+
program = Process.find_executable(program)
|
39
|
+
if program.nil?
|
40
|
+
puts "Can't find program #{arg1}"
|
41
|
+
raise "Error"
|
42
|
+
end
|
43
|
+
|
44
|
+
lines = STDIN.gets_to_end.strip
|
45
|
+
lines = lines.split "\n"
|
46
|
+
times = (lines.size % 2000000 == 0) ? 2 : 1
|
47
|
+
|
48
|
+
times += lines.size // 2000000
|
49
|
+
n = 0
|
50
|
+
times.times do
|
51
|
+
prog_args = args
|
52
|
+
|
53
|
+
prog_args += lines[n..(n + 2000000 - 1)]; n += 2000000
|
54
|
+
|
55
|
+
if (p = Process.fork).nil?
|
56
|
+
Process.exec(
|
57
|
+
program,
|
58
|
+
prog_args
|
59
|
+
)
|
60
|
+
else
|
61
|
+
p.wait
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def mul()
|
67
|
+
t = STDIN.read_line.to_f64
|
68
|
+
|
69
|
+
i = 0f64; STDIN.each_line do |line|
|
70
|
+
t *= line.to_f64
|
71
|
+
end
|
72
|
+
|
73
|
+
puts t
|
74
|
+
end
|
75
|
+
|
76
|
+
def add()
|
77
|
+
t = STDIN.read_line.to_f64
|
78
|
+
|
79
|
+
i = 0f64; STDIN.each_line do |line|
|
80
|
+
t += line.to_f64
|
81
|
+
end
|
82
|
+
|
83
|
+
puts t
|
84
|
+
end
|
85
|
+
|
86
|
+
def div()
|
87
|
+
t = STDIN.read_line.to_f64
|
88
|
+
|
89
|
+
i = 0f64; STDIN.each_line do |line|
|
90
|
+
t /= line.to_f64
|
91
|
+
end
|
92
|
+
|
93
|
+
puts t
|
94
|
+
end
|
95
|
+
|
96
|
+
def sub()
|
97
|
+
t = STDIN.read_line.to_f64
|
98
|
+
|
99
|
+
i = 0f64; STDIN.each_line do |line|
|
100
|
+
t -= line.to_f64
|
101
|
+
end
|
102
|
+
|
103
|
+
puts t
|
104
|
+
end
|
105
|
+
|
106
|
+
def floor()
|
107
|
+
puts STDIN.read_line.to_f64.to_i64
|
108
|
+
end
|
109
|
+
|
110
|
+
def abs()
|
111
|
+
STDIN.each_line do |l|
|
112
|
+
l = l.to_f64.abs
|
113
|
+
puts l
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def exp()
|
118
|
+
t = STDIN.read_line.to_f64
|
119
|
+
|
120
|
+
STDIN.each_line do |line|
|
121
|
+
t **= line.to_f64
|
122
|
+
end
|
123
|
+
|
124
|
+
puts t
|
125
|
+
end
|
126
|
+
|
127
|
+
def nth(arg1)
|
128
|
+
end_ = arg1.to_u64
|
129
|
+
i = 0u64; STDIN.each_line do |line|
|
130
|
+
i += 1
|
131
|
+
if i == end_
|
132
|
+
puts line
|
133
|
+
break
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def last_nth(arg1)
|
139
|
+
end_ = arg1.to_u64
|
140
|
+
i = 0u64
|
141
|
+
t = STDIN.gets_to_end
|
142
|
+
if t[-1] == '\n'
|
143
|
+
t = t[0..-2]
|
144
|
+
end
|
145
|
+
|
146
|
+
t.split("\n").reverse_each do |line|
|
147
|
+
i += 1
|
148
|
+
if i == end_
|
149
|
+
puts line
|
150
|
+
break
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def gsubip(arg1, arg2, arg3)
|
156
|
+
regex = Regex.new(arg1)
|
157
|
+
text = File.read(arg3).gsub(/#{arg1}/m, arg2)
|
158
|
+
File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(arg3).permissions) do |h|
|
159
|
+
h.print text
|
160
|
+
end
|
161
|
+
begin
|
162
|
+
File.rename t, arg3
|
163
|
+
rescue
|
164
|
+
rm t
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def rip(arg1, arg2, arg3)
|
169
|
+
text = File.read(arg3).gsub(arg1, arg2)
|
170
|
+
File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(arg3).permissions) do |h|
|
171
|
+
h.print text
|
172
|
+
end
|
173
|
+
begin
|
174
|
+
File.rename t, arg3
|
175
|
+
rescue
|
176
|
+
rm t
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def gsub(arg1, arg2)
|
181
|
+
print STDIN.gets_to_end.gsub(/#{arg1}/m, arg2)
|
182
|
+
end
|
183
|
+
|
184
|
+
def rnip(arg1, arg2)
|
185
|
+
print STDIN.gets_to_end.gsub(arg1, arg2)
|
186
|
+
end
|
187
|
+
|
188
|
+
def selectlines()
|
189
|
+
STDIN.each_line do |line|
|
190
|
+
if line.strip.size > 0
|
191
|
+
puts line
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def swap(file1, file2)
|
197
|
+
[file1, file2].each do |f|
|
198
|
+
File.exists?(f) || abort("No file named #{f.dump}")
|
199
|
+
end
|
200
|
+
t = File.tempname("coreutils", "_tmp")
|
201
|
+
|
202
|
+
File.rename file1, t
|
203
|
+
File.rename file2, file1
|
204
|
+
File.rename t, file2
|
205
|
+
end
|
206
|
+
|
207
|
+
def prepend(file)
|
208
|
+
file_data = File.read(file)
|
209
|
+
new_data = STDIN.gets_to_end
|
210
|
+
File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(file).permissions) do |h|
|
211
|
+
h << new_data + file_data
|
212
|
+
end
|
213
|
+
|
214
|
+
begin
|
215
|
+
File.rename t, file
|
216
|
+
rescue
|
217
|
+
rm t
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def append(file)
|
222
|
+
file_data = File.read(file)
|
223
|
+
new_data = STDIN.gets_to_end
|
224
|
+
File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(file).permissions) do |h|
|
225
|
+
h << file_data + new_data
|
226
|
+
end
|
227
|
+
begin
|
228
|
+
File.rename t, file
|
229
|
+
rescue
|
230
|
+
rm t
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
class Funcs
|
235
|
+
def self.argument_data(program, usage, long_desc)
|
236
|
+
if !(STDOUT.tty?)
|
237
|
+
text = "<div style='border-radius: 50px; border: 10px dotted cyan; padding: 30px;'>\n"
|
238
|
+
else
|
239
|
+
text = ""
|
240
|
+
end
|
241
|
+
|
242
|
+
text += ("NAME") + "\n\t" + program
|
243
|
+
text += " - "
|
244
|
+
text += program + "\n" * 2 + ("SYNOPSIS") + "\n"
|
245
|
+
# tebold_("SYNOPSIS_")# + bold("SYNOPSIS")
|
246
|
+
text += "\t"
|
247
|
+
text += (program) + " "
|
248
|
+
text += usage + "\n\n"
|
249
|
+
text += long_desc + "\n\n"
|
250
|
+
|
251
|
+
if STDOUT.tty? == false
|
252
|
+
text = text.gsub("\n", "<br/> ").gsub("\t", " " * 5)
|
253
|
+
text += "</div>\n\n"
|
254
|
+
end
|
255
|
+
|
256
|
+
puts text
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
def main()
|
262
|
+
if ARGV.size != 1
|
263
|
+
Funcs.argument_data("delete", "[delete] [arguments]", "Recursively delete all files named a certain name.")
|
264
|
+
exit 1
|
265
|
+
end
|
266
|
+
|
267
|
+
delete(ARGV[0])
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
main
|
@@ -1,9 +1,24 @@
|
|
1
1
|
#!/usr/bin/crystal
|
2
|
-
require "file_utils"
|
3
|
-
require "json"
|
4
|
-
require "colorize"
|
5
2
|
|
6
|
-
|
3
|
+
def delete(arg)
|
4
|
+
`find -name #{arg}`.each_line do |i|
|
5
|
+
File.delete(i)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def nth_word(arg)
|
11
|
+
i = arg.to_u64 - 1
|
12
|
+
STDIN.each_line do |line|
|
13
|
+
puts line.split[i] rescue ""
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def trim()
|
18
|
+
STDIN.each_line do |line|
|
19
|
+
puts line.strip
|
20
|
+
end
|
21
|
+
end
|
7
22
|
|
8
23
|
def lines()
|
9
24
|
if !STDIN.tty?
|
@@ -48,14 +63,6 @@ def args(arg1)
|
|
48
63
|
end
|
49
64
|
end
|
50
65
|
|
51
|
-
def copy()
|
52
|
-
command = "/usr/bin/xclip"
|
53
|
-
args = ["-selection", "c"]
|
54
|
-
Process.run(command, args, output: STDOUT) do |file|
|
55
|
-
file.input.print STDIN.gets_to_end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
66
|
def mul()
|
60
67
|
t = STDIN.read_line.to_f64
|
61
68
|
|
@@ -107,14 +114,6 @@ def abs()
|
|
107
114
|
end
|
108
115
|
end
|
109
116
|
|
110
|
-
def dump()
|
111
|
-
puts STDIN.gets_to_end.dump
|
112
|
-
end
|
113
|
-
|
114
|
-
def undump()
|
115
|
-
puts JSON.parse(STDIN.gets_to_end)
|
116
|
-
end
|
117
|
-
|
118
117
|
def exp()
|
119
118
|
t = STDIN.read_line.to_f64
|
120
119
|
|
@@ -138,10 +137,10 @@ end
|
|
138
137
|
|
139
138
|
def last_nth(arg1)
|
140
139
|
end_ = arg1.to_u64
|
141
|
-
i = 0u64
|
140
|
+
i = 0u64
|
142
141
|
t = STDIN.gets_to_end
|
143
142
|
if t[-1] == '\n'
|
144
|
-
|
143
|
+
t = t[0..-2]
|
145
144
|
end
|
146
145
|
|
147
146
|
t.split("\n").reverse_each do |line|
|
@@ -160,7 +159,7 @@ def gsubip(arg1, arg2, arg3)
|
|
160
159
|
h.print text
|
161
160
|
end
|
162
161
|
begin
|
163
|
-
|
162
|
+
File.rename t, arg3
|
164
163
|
rescue
|
165
164
|
rm t
|
166
165
|
end
|
@@ -172,7 +171,7 @@ def rip(arg1, arg2, arg3)
|
|
172
171
|
h.print text
|
173
172
|
end
|
174
173
|
begin
|
175
|
-
|
174
|
+
File.rename t, arg3
|
176
175
|
rescue
|
177
176
|
rm t
|
178
177
|
end
|
@@ -194,16 +193,15 @@ def selectlines()
|
|
194
193
|
end
|
195
194
|
end
|
196
195
|
|
197
|
-
|
198
196
|
def swap(file1, file2)
|
199
197
|
[file1, file2].each do |f|
|
200
|
-
File.exists?(f) || abort("No file named #{f.dump}"
|
198
|
+
File.exists?(f) || abort("No file named #{f.dump}")
|
201
199
|
end
|
202
200
|
t = File.tempname("coreutils", "_tmp")
|
203
201
|
|
204
|
-
|
205
|
-
|
206
|
-
|
202
|
+
File.rename file1, t
|
203
|
+
File.rename file2, file1
|
204
|
+
File.rename t, file2
|
207
205
|
end
|
208
206
|
|
209
207
|
def prepend(file)
|
@@ -214,7 +212,7 @@ def prepend(file)
|
|
214
212
|
end
|
215
213
|
|
216
214
|
begin
|
217
|
-
|
215
|
+
File.rename t, file
|
218
216
|
rescue
|
219
217
|
rm t
|
220
218
|
end
|
@@ -227,24 +225,13 @@ def append(file)
|
|
227
225
|
h << file_data + new_data
|
228
226
|
end
|
229
227
|
begin
|
230
|
-
|
228
|
+
File.rename t, file
|
231
229
|
rescue
|
232
230
|
rm t
|
233
231
|
end
|
234
232
|
end
|
235
233
|
|
236
234
|
class Funcs
|
237
|
-
def self.bold(text)
|
238
|
-
text = text.to_s
|
239
|
-
# text += two.to_s
|
240
|
-
|
241
|
-
if STDOUT.tty?
|
242
|
-
return text.colorize.bold.to_s
|
243
|
-
else
|
244
|
-
return "<b>" + text + "</b>"
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
235
|
def self.argument_data(program, usage, long_desc)
|
249
236
|
if !(STDOUT.tty?)
|
250
237
|
text = "<div style='border-radius: 50px; border: 10px dotted cyan; padding: 30px;'>\n"
|
@@ -252,12 +239,12 @@ class Funcs
|
|
252
239
|
text = ""
|
253
240
|
end
|
254
241
|
|
255
|
-
text +=
|
242
|
+
text += ("NAME") + "\n\t" + program
|
256
243
|
text += " - "
|
257
|
-
text += program + "\n" * 2 +
|
244
|
+
text += program + "\n" * 2 + ("SYNOPSIS") + "\n"
|
258
245
|
# tebold_("SYNOPSIS_")# + bold("SYNOPSIS")
|
259
246
|
text += "\t"
|
260
|
-
text +=
|
247
|
+
text += (program) + " "
|
261
248
|
text += usage + "\n\n"
|
262
249
|
text += long_desc + "\n\n"
|
263
250
|
|
@@ -267,12 +254,10 @@ class Funcs
|
|
267
254
|
end
|
268
255
|
|
269
256
|
puts text
|
270
|
-
|
271
|
-
# puts "</
|
272
|
-
# puts "</
|
273
257
|
end
|
274
258
|
end
|
275
259
|
|
260
|
+
|
276
261
|
def main()
|
277
262
|
if ARGV.size != 0
|
278
263
|
Funcs.argument_data("div", "[div] [arguments]", "Divides numbers\n\nExample\n\n(echo 5000; echo 100) | div\n\n=> 50")
|