View difference between Paste ID: e4xWYwqm and yg6qwYfE
SHOW: | | - or go back to the newest paste.
1
local tArgs = {...}
2
local text = "HD's pc wiper v3.0"
3
local maxX, maxY = term.getSize()
4
local Z = shell.getRunningProgram()
5
6
if tArgs[1] == "-help" then
7
 print("This is HD's computercraft wiper")
8
 print("This program will wipe everything it can")
9
 print("unless it is an argument or the program itself")
10
 print("")
11
 print('Example: "'..Z..' test"')
12
 print("This will wipe everything but test and "..Z)
13
 error()
14
end
15
16
if term.isColour() then
17
 term.setTextColour(colors.red)
18
end
19
20
term.clear()
21
term.setCursorPos(1,1)
22
23
for i=1, maxX do
24
 write("-")
25
end
26
27
write("|")
28
term.setCursorPos(maxX/2-#text/2, 2)
29
write(text)
30
term.setCursorPos(maxX, 2)
31
write("|")
32
33
for i=1, maxX do write("-") end
34
print("")
35
36
local Z = shell.getRunningProgram()
37
local fileTable = fs.list("/")
38
table.sort(fileTable)
39
40
if term.isColour() then
41
 term.setTextColour(colors.orange)
42
end
43
44
function checkArg(str)
45
 for i,v in ipairs(tArgs) do
46
  if str == v then return false end
47
 end
48
 return true
49
end
50
51
function drawBox(text, state)
52
 if term.isColour() then
53
  if state == true then
54
   term.setTextColour(colors.orange)
55
  elseif state == false then
56
   term.setTextColour(colors.lime)
57
  else
58
   term.setTextColour(colors.blue)
59
  end
60
 end
61
 
62
 local maxX, maxY = term.getSize()
63
 
64
 
65
 for i=1, maxX do
66
  write("-")
67
 end
68
 
69
 write("|")
70
 local xPos, yPos = term.getCursorPos()
71
 term.setCursorPos(maxX/2-#text/2, yPos)
72
 write(text)
73
 
74
 term.setCursorPos(maxX, yPos)
75
 write("|")
76
 
77
 for i=1, maxX do
78
  write("-")
79
 end
80
end
81
82
for i,v in ipairs(fileTable) do
83
 os.queueEvent("") os.pullEvent()
84
 if v ~= Z and not fs.isReadOnly(v) and checkArg(v)==true then
85
  local text = "Deleting: "..v
86
  drawBox(text, true)
87
  fs.delete(v)
88
 else
89
  local text = "Skipping: "..v
90
  drawBox(text, false)
91
 end
92
end
93
94
drawBox("Press any key to continue")
95
os.pullEvent("key")
96
term.clear()
97
term.setCursorPos(1,1)