51 lines
1.2 KiB
Lua
51 lines
1.2 KiB
Lua
local createVersion = require('/apis/libversion');
|
|
|
|
local function printUsage()
|
|
print('trapos-postinstall usage:');
|
|
print();
|
|
print('\t\ttrapos-postinstall');
|
|
print('\t\ttrapos-postinstall version');
|
|
print('\t\ttrapos-postinstall help');
|
|
end
|
|
|
|
local command = ...;
|
|
|
|
if command == 'version' or command == '-version' or command == '--version' then
|
|
print('v' .. createVersion().forSelf());
|
|
return;
|
|
end
|
|
|
|
if command == 'help' or command == '-help' or command == '--help' then
|
|
printUsage();
|
|
return;
|
|
end
|
|
|
|
if command ~= nil and command ~= '' then
|
|
printUsage();
|
|
return;
|
|
end
|
|
|
|
local function readManifestVersion()
|
|
if not fs.exists('/trapos/manifest.json') then return nil; end
|
|
local f = fs.open('/trapos/manifest.json', 'r');
|
|
if not f then return nil; end
|
|
local data = f.readAll();
|
|
f.close();
|
|
local manifest = data and textutils.unserializeJSON(data);
|
|
return manifest and manifest.version or nil;
|
|
end
|
|
|
|
local version = readManifestVersion();
|
|
|
|
print();
|
|
if version then
|
|
print('=> TrapOS v' .. version .. ' installed.');
|
|
else
|
|
print('=> TrapOS installed.');
|
|
end
|
|
print();
|
|
print('Get started:');
|
|
print(' sandbox --help -- open the sandbox help');
|
|
print(' trapos-upgrade -- update and upgrade TrapOS');
|
|
print();
|