mirror of
https://github.com/kepler155c/opus
synced 2025-05-13 12:54:10 +00:00
open editor for config on first run
This commit is contained in:
parent
dc9d174085
commit
1528bab3ac
@ -1,10 +1,11 @@
|
|||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
|
local shell = _ENV.shell
|
||||||
|
|
||||||
local Config = { }
|
local Config = { }
|
||||||
|
|
||||||
Config.load = function(fname, data)
|
function Config.load(fname, data)
|
||||||
local filename = 'usr/config/' .. fname
|
local filename = 'usr/config/' .. fname
|
||||||
|
|
||||||
if not fs.exists('usr/config') then
|
if not fs.exists('usr/config') then
|
||||||
@ -18,7 +19,24 @@ Config.load = function(fname, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Config.update = function(fname, data)
|
function Config.loadWithCheck(fname, data)
|
||||||
|
local filename = 'usr/config/' .. fname
|
||||||
|
|
||||||
|
if not fs.exists(filename) then
|
||||||
|
Config.load(fname, data)
|
||||||
|
print()
|
||||||
|
print('The configuration file has been created.')
|
||||||
|
print('The file name is: ' .. filename)
|
||||||
|
print()
|
||||||
|
_G.printError('Press enter to configure')
|
||||||
|
_G.read()
|
||||||
|
shell.run('edit ' .. filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
Config.load(fname, data)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Config.update(fname, data)
|
||||||
local filename = 'usr/config/' .. fname
|
local filename = 'usr/config/' .. fname
|
||||||
Util.writeTable(filename, data)
|
Util.writeTable(filename, data)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user