Skip to content

Commit f49b5f6

Browse files
ChristophLHRColdIV
andcommitted
Formatted Files
Co-authored-by: Josh <[email protected]>
1 parent 39a8553 commit f49b5f6

File tree

8 files changed

+41
-55
lines changed

8 files changed

+41
-55
lines changed

libs/scm/config.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
2-
31
---@class SCMConfig
42
local Config = {}
53
SCM.Config = Config
64
do
7-
8-
95
---@class SCMConfigData
106
Config.config = {
117
-- Git Settings (In this case on GitHub, not tested with others)
@@ -57,7 +53,7 @@ do
5753
---@param config SCMConfigData | nil
5854
function Config:saveConfig(config)
5955
config = config or self.config
60-
56+
6157
local file = fs.open(config["configDirectory"] .. config["configFile"], "w")
6258
if not file then
6359
os.execute("mkdir " .. config["configDirectory"])

libs/scm/ui.lua

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
local UI = {}
33
SCM.UI = UI
44
do
5-
--Redundant
6-
function UI:printUsage()
7-
print("Usage: scm <command> [args]")
8-
print("Commands:")
9-
print(" add <name> [src]")
10-
print(" update [name] [src]")
11-
print(" remove <name>")
12-
print(" list")
13-
print(" config <name> [value]")
14-
end
15-
165
function UI:listScripts()
176
local scripts = SCM.ScriptManager.scripts
187
print("name", "type")

scmInstaller.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function SCMInstaller:deleteFiles(files)
2727
end
2828
end
2929

30-
-- download the files
3130
function SCMInstaller:downloadFiles(source, files)
3231
for index, value in ipairs(files) do
3332
print('Downloading ' .. index .. ' of ' .. #files .. ' files: ' .. value)

tests/Suite/fs.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fs.progPath = "tmpProg/"
66
do
77
fs.open = function(path, mode)
88
assert("string" == type(path), tostring(path) .. "path must be a string")
9-
assert("string" == type(mode), tostring(mode) .." mode must be a string")
9+
assert("string" == type(mode), tostring(mode) .. " mode must be a string")
1010
local file = io.open(path, mode)
1111
if not file then
1212
-- find all occurences of / in the path
@@ -27,13 +27,13 @@ do
2727
file = io.open(path, mode)
2828
end
2929
if mode == "w" then
30-
assert(file, "file could not be opened in : "..path.. " Mode : "..mode)
30+
assert(file, "file could not be opened in : " .. path .. " Mode : " .. mode)
3131
end
3232
if not file then
3333
return nil
3434
end
3535
local file2 = {}
36-
setmetatable(file2, {__index = file})
36+
setmetatable(file2, { __index = file })
3737
file2.base = file
3838
file2.readAll = function()
3939
return file2.base:read("*a")
@@ -68,7 +68,7 @@ do
6868
assert("string" == type(dest), "dest must be a string")
6969
local file = io.open(src, "r")
7070
if not file then
71-
print("file "..src.." not found")
71+
print("file " .. src .. " not found")
7272
return false
7373
end
7474
local content = file:read("*a")
@@ -93,7 +93,7 @@ do
9393
end
9494
file = io.open(dest, "w")
9595
if not file then
96-
print("file"..dest.." not found")
96+
print("file" .. dest .. " not found")
9797
return false
9898
end
9999
end
@@ -125,13 +125,13 @@ do
125125
end
126126
end
127127

128-
fs.delete = function (path)
128+
fs.delete = function(path)
129129
assert("string" == type(path), "path must be a string")
130130
if fs.exists(path) then
131131
os.execute("rm -rf " .. path)
132132
end
133133
end
134-
fs.readAll = function (path)
134+
fs.readAll = function(path)
135135
assert("string" == type(path), "path must be a string")
136136
local file = io.open(path, "r")
137137
if not file then
@@ -142,4 +142,4 @@ do
142142
return content
143143
end
144144
end
145-
return fs
145+
return fs

tests/Suite/helperFunctions.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function table.copy(t)
2-
local u = { }
2+
local u = {}
33
for k, v in pairs(t) do u[k] = v end
44
return setmetatable(u, getmetatable(t))
5-
end
5+
end

tests/Suite/json.lua

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ local function kind_of(obj)
5050
end
5151

5252
local function escape_str(s)
53-
local in_char = {'\\', '"', '/', '\b', '\f', '\n', '\r', '\t'}
54-
local out_char = {'\\', '"', '/', 'b', 'f', 'n', 'r', 't'}
53+
local in_char = { '\\', '"', '/', '\b', '\f', '\n', '\r', '\t' }
54+
local out_char = { '\\', '"', '/', 'b', 'f', 'n', 'r', 't' }
5555
for i, c in ipairs(in_char) do
5656
s = s:gsub(c, '\\' .. out_char[i])
5757
end
@@ -80,10 +80,10 @@ local function parse_str_val(str, pos, val)
8080
local early_end_error = 'End of input found while parsing string.'
8181
if pos > #str then error(early_end_error) end
8282
local c = str:sub(pos, pos)
83-
if c == '"' then return val, pos + 1 end
83+
if c == '"' then return val, pos + 1 end
8484
if c ~= '\\' then return parse_str_val(str, pos + 1, val .. c) end
8585
-- We must have a \ character.
86-
local esc_map = {b = '\b', f = '\f', n = '\n', r = '\r', t = '\t'}
86+
local esc_map = { b = '\b', f = '\f', n = '\n', r = '\r', t = '\t' }
8787
local nextc = str:sub(pos + 1, pos + 1)
8888
if not nextc then error(early_end_error) end
8989
return parse_str_val(str, pos + 2, val .. (esc_map[nextc] or nextc))
@@ -101,8 +101,8 @@ end
101101
-- Public values and functions.
102102

103103
function json.stringify(obj, as_key)
104-
local s = {} -- We'll build the string as an array of strings to be concatenated.
105-
local kind = kind_of(obj) -- This is 'array' if it's an array or type(obj) otherwise.
104+
local s = {} -- We'll build the string as an array of strings to be concatenated.
105+
local kind = kind_of(obj) -- This is 'array' if it's an array or type(obj) otherwise.
106106
if kind == 'array' then
107107
if as_key then error('Can\'t encode array as key.') end
108108
s[#s + 1] = '['
@@ -136,25 +136,25 @@ function json.stringify(obj, as_key)
136136
return table.concat(s)
137137
end
138138

139-
json.null = {} -- This is a one-off table to represent the null value.
139+
json.null = {} -- This is a one-off table to represent the null value.
140140

141141
function json.parse(str, pos, end_delim)
142142
pos = pos or 1
143143
if pos > #str then error('Reached unexpected end of input.') end
144-
local pos = pos + #str:match('^%s*', pos) -- Skip whitespace.
144+
local pos = pos + #str:match('^%s*', pos) -- Skip whitespace.
145145
local first = str:sub(pos, pos)
146-
if first == '{' then -- Parse an object.
146+
if first == '{' then -- Parse an object.
147147
local obj, key, delim_found = {}, true, true
148148
pos = pos + 1
149149
while true do
150150
key, pos = json.parse(str, pos, '}')
151151
if key == nil then return obj, pos end
152152
if not delim_found then error('Comma missing between object items.') end
153-
pos = skip_delim(str, pos, ':', true) -- true -> error if missing.
153+
pos = skip_delim(str, pos, ':', true) -- true -> error if missing.
154154
obj[key], pos = json.parse(str, pos)
155155
pos, delim_found = skip_delim(str, pos, ',')
156156
end
157-
elseif first == '[' then -- Parse an array.
157+
elseif first == '[' then -- Parse an array.
158158
local arr, val, delim_found = {}, true, true
159159
pos = pos + 1
160160
while true do
@@ -164,14 +164,14 @@ function json.parse(str, pos, end_delim)
164164
arr[#arr + 1] = val
165165
pos, delim_found = skip_delim(str, pos, ',')
166166
end
167-
elseif first == '"' then -- Parse a string.
167+
elseif first == '"' then -- Parse a string.
168168
return parse_str_val(str, pos + 1)
169-
elseif first == '-' or first:match('%d') then -- Parse a number.
169+
elseif first == '-' or first:match('%d') then -- Parse a number.
170170
return parse_num_val(str, pos)
171-
elseif first == end_delim then -- End of an object or array.
171+
elseif first == end_delim then -- End of an object or array.
172172
return nil, pos + 1
173-
else -- Parse true, false, or null.
174-
local literals = {['true'] = true, ['false'] = false, ['null'] = json.null}
173+
else -- Parse true, false, or null.
174+
local literals = { ['true'] = true, ['false'] = false, ['null'] = json.null }
175175
for lit_str, lit_val in pairs(literals) do
176176
local lit_end = pos + #lit_str - 1
177177
if str:sub(pos, lit_end) == lit_str then return lit_val, lit_end + 1 end
@@ -181,4 +181,4 @@ function json.parse(str, pos, end_delim)
181181
end
182182
end
183183

184-
return json
184+
return json

tests/testSuite.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ _G.http = {
3030
_G.shell = {
3131
-- TODO: implement shell - CompleteFunction
3232
["setCompletionFunction"] = function(...) return end,
33-
["run"] = function (...) return end
33+
["run"] = function(...) return end
3434
}
3535

3636
-- Just any day, does not matter as of now

tests/test_spec.lua

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ end
9090
describe("Testing everything about SCM:", function()
9191
--only neccessary for local testing
9292
describe("Copy Files", function()
93-
9493
assert.is_true(fs.copy("./scm.lua", "tmpFiles/scm.lua"), "Could not copy scm.lua")
9594
assert.is_true(fs.copy("./libs/scm/config.lua", "tmpFiles/config.lua"), "Could not copy config.lua")
9695
assert.is_true(fs.copy("./libs/scm/net.lua", "tmpFiles/net.lua"), "Could not copy net.lua")
9796
assert.is_true(fs.copy("./libs/scm/log.lua", "tmpFiles/log.lua"), "Could not copy log.lua")
98-
assert.is_true(fs.copy("./libs/scm/scriptManager.lua", "tmpFiles/scriptManager.lua"), "Could not copy scriptManager.lua")
99-
assert.is_true(fs.copy("./libs/scm/autocomplete.lua", "tmpFiles/autocomplete.lua"), "Could not copy autocomplete.lua")
97+
assert.is_true(fs.copy("./libs/scm/scriptManager.lua", "tmpFiles/scriptManager.lua"),
98+
"Could not copy scriptManager.lua")
99+
assert.is_true(fs.copy("./libs/scm/autocomplete.lua", "tmpFiles/autocomplete.lua"),
100+
"Could not copy autocomplete.lua")
100101
assert.is_true(fs.copy("./libs/scm/ui.lua", "tmpFiles/ui.lua"), "Could not copy ui.lua")
101102
end)
102103

@@ -163,10 +164,10 @@ describe("Testing everything about SCM:", function()
163164
end
164165
)
165166
end)
166-
describe("Load Remote", function ()
167+
describe("Load Remote", function()
167168
it("Get TestLib", function()
168169
runTests(
169-
---@param scm SCM
170+
---@param scm SCM
170171
function(scm)
171172
local testScript = scm:load("scmTest")
172173
local scriptManager = scm.ScriptManager
@@ -179,14 +180,13 @@ describe("Testing everything about SCM:", function()
179180
describe("Update SCM", function()
180181
it("Update SCM", function()
181182
runTests(
182-
---@param scm SCM
183+
---@param scm SCM
183184
function(scm)
184185
-- TODO: implement
185186
end
186187
)
187188
end)
188189
end)
189-
190190
end)
191191

192192
-- only neccessary for local testing
@@ -195,9 +195,11 @@ describe("Testing everything about SCM:", function()
195195
assert.is_true(fs.copy("tmpFiles/config.lua", "./libs/scm/config.lua"), "Could not restore config.lua")
196196
assert.is_true(fs.copy("tmpFiles/net.lua", "./libs/scm/net.lua"), "Could not restore net.lua")
197197
assert.is_true(fs.copy("tmpFiles/log.lua", "./libs/scm/log.lua"), "Could not restore log.lua")
198-
assert.is_true(fs.copy("tmpFiles/scriptManager.lua", "./libs/scm/scriptManager.lua"), "Could not restore scriptManager.lua")
199-
assert.is_true(fs.copy("tmpFiles/autocomplete.lua", "./libs/scm/autocomplete.lua"), "Could not restore autocomplete.lua")
198+
assert.is_true(fs.copy("tmpFiles/scriptManager.lua", "./libs/scm/scriptManager.lua"),
199+
"Could not restore scriptManager.lua")
200+
assert.is_true(fs.copy("tmpFiles/autocomplete.lua", "./libs/scm/autocomplete.lua"),
201+
"Could not restore autocomplete.lua")
200202
assert.is_true(fs.copy("tmpFiles/ui.lua", "./libs/scm/ui.lua"), "Could not restore ui.lua")
201203
os.execute("rm --recursive ./tmpFiles")
202204
end)
203-
end)
205+
end)

0 commit comments

Comments
 (0)