Skip to content

Commit

Permalink
add cli
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestalmage committed Oct 20, 2020
1 parent a874c72 commit a484ed0
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 72 deletions.
3 changes: 0 additions & 3 deletions api/010-Controls-IO.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ***********
-- Controls IO
-- ***********
---@class Control
---@field public Value number Floating point value of control.
---@field public Values number[] Table of floating point values of controls. Only used when connected to controls that create tables of values such as the 2D panner, RTA - Band-Pass or Responsalyzer, Meters.
Expand Down
4 changes: 0 additions & 4 deletions api/020-ChannelGroup.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- ************
-- ChannelGroup
-- ************

---Used when a Control Script is located inside a Channel Group. The .Index property is used to determine which Channel Group is currently selected
---@field public Index number value, 1-n, indicates which channel of the Channel Group, 0 indicated not in Channel Group. If multiple groups are selected, the index of the first group is returned.
ChannelGroup = {}
4 changes: 0 additions & 4 deletions api/030-Crypto.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- ************
-- Crypto
-- ************

--- Use the Crypto commands to encode and decode ASCII text strings to and from Base64, as well as obtain CRC16, HMAC, and MD5 values for specified strings.
Crypto = {}

Expand Down
4 changes: 0 additions & 4 deletions api/040-Design.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- ************
-- Design
-- ************

---@class DesignStatus A status table containing design information
---@field public DesignName string The name of the design file.
---@field public Platform string "Emulator" or The model of the running core.
Expand Down
3 changes: 0 additions & 3 deletions api/050-dir (Directory).lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ************
-- dir
-- ************
---Use the directory commands to list folders and files, create folders, and delete folders within the media/ or design/ locations on the file system. For security and stability reasons, these are the only locations accessible by the Lua libraries.
---
---The media/ folder is the location for all media files, while the design/ folder is the location where uncompressed design configuration files reside while a design is being emulated or running on a Q-SYS Core processor. (It is not intended for storage of user-created design files, and is not remotely accessible.)
Expand Down
3 changes: 0 additions & 3 deletions api/060-Email.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ************
-- Email
-- ************
---@alias EmailSendHandler fun(table: EmailSendParameters, error: string)

---@class EmailSendParameters A table containing the details of the email to be sent.
Expand Down
4 changes: 0 additions & 4 deletions api/070-HttpClient.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

-- ****************
-- HttpClient
-- ****************
---@class HttpDownloadParams
---@field public Url string The URL to download from
---@field public Headers table<string, string> A table of headers
Expand Down
3 changes: 0 additions & 3 deletions api/080-JSON.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- **********
-- json
-- **********
json = {}

---Encodes the Lua object into a JSON string
Expand Down
3 changes: 0 additions & 3 deletions api/090-Log.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- **********
-- Log
-- **********
---The Log object is used to write messages to the Core's system log file.
Log = {}

Expand Down
3 changes: 0 additions & 3 deletions api/110-NamedControl.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ******************
-- NamedControl
-- ******************
---The methods in NamedControl are used to read or set the values of Named Controls.
---
---Create Named Controls by dragging specific controls (knobs, buttons, faders, etc) to
Expand Down
3 changes: 0 additions & 3 deletions api/120-Component.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ******************
-- Component
-- ******************
---@see Control Similar to regular Control. Has an extra Name field.
---@class ControlWithName: Control
---@field public Name string
Expand Down
3 changes: 0 additions & 3 deletions api/130-Network.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ******************
-- Network
-- ******************
---Use the Network commands to return the full host name and IP address of a specified host, or obtain a table of network interface names and their IP addresses.
Network = {}

Expand Down
3 changes: 0 additions & 3 deletions api/140-Notifications.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ******************
-- Notifications
-- ******************
--- Message pub/sub that works across the design
Notifications = {}

Expand Down
3 changes: 0 additions & 3 deletions api/150-Ping.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ************
-- Ping
-- ************
---**Note:** The Lua Ping library requires that you run Q-SYS Designer as administrator ("Run as administrator" option in Windows) when emulating your design. If you see a non-terminating "Socket failed to open" error message in the debug window, re-launch Designer as administrator.
---@class Ping
Ping = {}
Expand Down
1 change: 0 additions & 1 deletion api/180-SerialServerPorts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ function SerialServerPort:Search(string, start_pos) end

---@type SerialServerPort[]
SerialServerPorts = {}

2 changes: 1 addition & 1 deletion api/200-SNMPTrap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ SNMPTrap = {}
---@param trapName string
function SNMPTrap.New(trapName) end

function SNMPTrap:startSession() end
function SNMPTrap:startSession() end
2 changes: 1 addition & 1 deletion api/210-Ssh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ Ssh.Events = {}
---@field public Lf SshEOL
---@field public Null SshEOL
---@field public Custom SshEOL
Ssh.EOL = {}
Ssh.EOL = {}
2 changes: 1 addition & 1 deletion api/230-TcpSocket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ TcpSocket.Events = {}
---@field public Lf SocketEOL
---@field public Null SocketEOL
---@field public Custom SocketEOL
TcpSocket.EOL = {}
TcpSocket.EOL = {}
2 changes: 1 addition & 1 deletion api/240-TcpSocketServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ function TcpSocketServer:New() end
function TcpSocketServer:Listen(port) end

---Stops listening
function TcpSocketServer:Close() end
function TcpSocketServer:Close() end
1 change: 0 additions & 1 deletion api/250-Timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ function Timer:Stop() end
---@param fun fun() The callback to be called.
---@param delay number The delay in seconds.
function Timer.CallAfter(fun, delay) end

2 changes: 1 addition & 1 deletion api/260-Uci.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ function Uci.SetSharedLayerVisibility(uciName, layerName, visibility, transitio

---Log off from a specified TSC touchscreen controller or UCI Viewer.
---@param tscName string The name of the TSC touchscreen controller or UCI Viewer.
function Uci.LogOff(tscName) end
function Uci.LogOff(tscName) end
2 changes: 1 addition & 1 deletion build-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const content = fs.readdirSync(apiDir)
.map(({filename, filepath}) => ({filename, contents: fs.readFileSync(filepath, 'utf8')}))
.map(({filename, contents}) => {
const dividerLine = `-- ${repeat('*', filename.length * 3)}`;
const filenameLine = `-- ${repeat(' ', filename.length)}`;
const filenameLine = `-- ${repeat(' ', filename.length)}${filename}`;
return `${dividerLine}\n${filenameLine}\n${dividerLine}\n${contents}`
})
.join('\n');
Expand Down
28 changes: 28 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env node
'use strict';
const fs = require('fs')
const path = require('path');
const argv = require('yargs-parser')(process.argv.slice(2));
const apiTypes = require('.');

if (argv.version) {
console.log(require('./package.json').version);
return;
}

let output = argv.output || argv.out || argv.o;

if (output) {
if (output === true) {
output = path.join(process.cwd(), 'qsys-api-types.lua');
} else if (typeof output === 'string') {
output = path.join(process.cwd(), output);
} else {
throw new Error('TypeError: output ' + output);
}

fs.writeFileSync(output, apiTypes.contents);
return;
}

console.log(apiTypes.contents);
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ const path = require('path');

const filepath = path.join(__dirname, 'qsys-api-types.lua');

let contents;

module.exports = {
path: filepath,
get contents() {
// lazy load.
const contents = fs.readFileSync(filepath, 'utf8');
Object.defineProperty(module.exports, 'contents', {
value: contents,
enumerable: true
});
if (!contents) {
contents = fs.readFileSync(filepath, 'utf8');
}
return contents;
}
};
27 changes: 16 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
"url": "https://github.com/qsys-tools/qsys-api-types/issues"
},
"homepage": "https://github.com/qsys-tools/qsys-api-types#readme",
"bin": "./cli.js",
"files": [
"index.js",
"qsys-api-types.lua"
],
"dependencies": {
"repeat-string": "^1.6.1"
"repeat-string": "^1.6.1",
"yargs-parser": "^20.2.3"
},
"scripts": {
"build": "node ./build-api.js",
"test": "echo nothing to test",
"prepublishOnly": "node ./build-api.js"
},
Expand Down

0 comments on commit a484ed0

Please sign in to comment.