Skip to content

Commit b50f0bd

Browse files
committed
add option for cli prefix
1 parent 7907e3c commit b50f0bd

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

scm.lua

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ scm.config = {
2626
["logDate"] = false,
2727
["writeLogFile"] = false,
2828
["logFilePath"] = "logs/scm-log.txt",
29-
["repoScriptsFile"] = "scm-repo-scripts.txt" -- will be saved in configDirectory as well
29+
["repoScriptsFile"] = "scm-repo-scripts.txt", -- will be saved in configDirectory as well
30+
["allowCLIPrefix"] = true,
31+
["cliPrefix"] = false
3032
}
3133
----------------
3234

@@ -852,8 +854,15 @@ function scm:cli (resetPosition, args)
852854
self:prepareAutocomplete()
853855
updateAutocomplete()
854856

857+
-- enable newline starting with `scm `
858+
if self.config["allowCLIPrefix"] then
859+
self.config["cliPrefix"] = true
860+
self:saveConfig()
861+
end
862+
855863
-- some interface
856864
local _, cursorY = term.getCursorPos()
865+
if cursorY < 7 then cursorY = 7 end
857866
term.setCursorPos(1, cursorY)
858867
term.blit(" ","ffffffffffffffffffffffffffffffff","44444444444444444444444444444444")
859868
term.setCursorPos(1, cursorY)
@@ -871,8 +880,8 @@ function scm:cli (resetPosition, args)
871880
term.setCursorPos(1, cursorY)
872881
term.scroll(2)
873882

874-
if args and #args == 0 then
875-
read(nil, nil, shell.complete, "scm ")
883+
if self.config["cliPrefix"] then
884+
shell.run(read(nil, nil, shell.complete, "scm "))
876885
end
877886
end
878887

@@ -885,6 +894,9 @@ function scm:handleArguments (args)
885894

886895
if args[1] and self.commands[args[1]] then
887896
self.commands[args[1]]["func"](args)
897+
if self.config["cliPrefix"] then
898+
shell.run(read(nil, nil, shell.complete, "scm "))
899+
end
888900
end
889901
end
890902

0 commit comments

Comments
 (0)