add the beep app
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
local computer = require("computer")
|
||||||
|
local cliparse = require("cliparse")
|
||||||
|
|
||||||
|
cliparse.config({
|
||||||
|
["f"] = 1,
|
||||||
|
["frequency"] = 1,
|
||||||
|
["t"] = 1,
|
||||||
|
["time"] = 1,
|
||||||
|
})
|
||||||
|
local parsed, err = cliparse.parse(...)
|
||||||
|
if not parsed then
|
||||||
|
return print("\x1b[91m" .. err)
|
||||||
|
end
|
||||||
|
|
||||||
|
local freq =
|
||||||
|
tonumber(parsed.flags.f and parsed.flags.f[1] or parsed.flags.frequency and parsed.flags.frequency[1] or "440")
|
||||||
|
local time = tonumber(parsed.flags.t and parsed.flags.t[1] or parsed.flags.time and parsed.flags.time[1] or "0.1")
|
||||||
|
|
||||||
|
computer.beep(freq, time)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Usage: beep [FLAGS]
|
||||||
|
Make the computer beep.
|
||||||
|
|
||||||
|
FLAGS
|
||||||
|
-f, --frequency Specifies the frequency, in Hz. Defaults to 440Hz.
|
||||||
|
-t, --time Specifies how long, in seconds, the computer should beep. Defaults to 0.1s.
|
||||||
Reference in New Issue
Block a user