ufos 1.0.79 → 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 != 0
|
278
263
|
Funcs.argument_data("exp", "[exp] [arguments]", "exp is an exponentiation tool\n\n(echo 5; echo 3) | exp\n\n=> 125\n\n(echo 2; echo 10) | exp\n\n=> 1024")
|
@@ -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("floor", "[floor] [arguments]", "Gets the floor of numbers e.g. 21.3 -> 21")
|
@@ -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 != 2
|
278
263
|
Funcs.argument_data("gsub", "[gsub] [arguments]", "Gsub is very powerful.\n\nUsage\n\ngsub [regular expression] [replacement text] \n\nExample\n\ncat text | gsub man dog\n\ncat text | gsub 'man|boy|cat|dog' food\n\nls | gsub Desktop cat")
|
@@ -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 != 3
|
278
263
|
Funcs.argument_data("gsubip", "[gsubip] [arguments]", "Global Substitute (Gsub) In Place\n\ngsubip is like gsub, which replaces all instances of a regular expression globally\n\n[regular expression 1] [regular expression 2] => result\n\nExample\n\ngsubip . FOO file\n\nWould make all characters in “file” become “FOO”\n\ngsubip cat dog file\n\nWould make all instances of “cat” “dog”\n\nIt is much cleaner than “sed.”\n\nYou don't need to have “sed” installed to run this program.\n\nIt doesn't read from the standard input\n\nIt takes exactly 3 arguments, no more, no fewer.\n\nSee also\n\ngsub")
|