pinnacle/api/lua/pinnacle.lua

51 lines
1.4 KiB
Lua
Raw Normal View History

-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at https://mozilla.org/MPL/2.0/.
2024-01-12 04:58:35 +01:00
local client = require("pinnacle.grpc.client")
---The entry point to configuration.
---
---This module contains one function: `setup`, which is how you'll access all the ways to configure Pinnacle.
2024-02-08 04:39:56 +01:00
---@class Pinnacle
2024-01-13 00:20:34 +01:00
local pinnacle = {
2024-02-08 04:39:56 +01:00
---@type Input
input = require("pinnacle.input"),
---@type Tag
tag = require("pinnacle.tag"),
---@type Output
output = require("pinnacle.output"),
---@type Window
window = require("pinnacle.window"),
---@type Process
process = require("pinnacle.process"),
2024-01-13 00:20:34 +01:00
}
2024-01-12 04:58:35 +01:00
---Quit Pinnacle.
2024-02-08 04:39:56 +01:00
function pinnacle.quit()
client.unary_request({
2024-01-12 04:58:35 +01:00
service = "pinnacle.v0alpha1.PinnacleService",
method = "Quit",
request_type = "pinnacle.v0alpha1.QuitRequest",
data = {},
})
end
---Setup Pinnacle.
2024-01-15 03:03:58 +01:00
---
2024-02-08 04:39:56 +01:00
---You must pass in a function that takes in the `Pinnacle` table. This table is how you'll access the other config modules.
2024-01-16 23:24:34 +01:00
---
2024-02-08 04:39:56 +01:00
---You can also `require` the other modules. Just be sure not to call any of their functions outside this
---setup function.
2024-01-15 03:03:58 +01:00
---
2024-01-12 04:58:35 +01:00
---@param config_fn fun(pinnacle: Pinnacle)
function pinnacle.setup(config_fn)
require("pinnacle.grpc.protobuf").build_protos()
2024-01-13 00:20:34 +01:00
2024-02-08 04:39:56 +01:00
config_fn(pinnacle)
2024-01-12 04:58:35 +01:00
2024-02-08 04:39:56 +01:00
client.loop:loop()
2024-01-12 04:58:35 +01:00
end
return pinnacle