aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordvs12024-10-25 09:38:35 +1000
committerdvs12024-10-25 09:38:35 +1000
commit31566d68cb3365ead1cdc8648c81d62ce966cb6f (patch)
treebbe3d4bc790530c6e955e21b18d1150d6036f73a
parentYet another TODO, YATODO. (diff)
downloadJackOnAllDevices-31566d68cb3365ead1cdc8648c81d62ce966cb6f.zip
JackOnAllDevices-31566d68cb3365ead1cdc8648c81d62ce966cb6f.tar.gz
JackOnAllDevices-31566d68cb3365ead1cdc8648c81d62ce966cb6f.tar.bz2
JackOnAllDevices-31566d68cb3365ead1cdc8648c81d62ce966cb6f.tar.xz
Just discovered the arg variable, use it and rename parseArgs() to just parse().
Diffstat (limited to '')
-rwxr-xr-x_.lua6
-rwxr-xr-xaataaj.lua9
-rwxr-xr-xtest_.lua10
3 files changed, 14 insertions, 11 deletions
diff --git a/_.lua b/_.lua
index 88100aa..390d6d1 100755
--- a/_.lua
+++ b/_.lua
@@ -24,7 +24,7 @@ E = function(s) print('ERROR ' .. s); io.flush() end
24C = function(s) print('CRITICAL ' .. s); io.flush() end 24C = function(s) print('CRITICAL ' .. s); io.flush() end
25 25
26 26
27_.parseArgs = function(options, args) 27_.parse = function(args, options)
28--[[ TODO - use this for config files as well. 28--[[ TODO - use this for config files as well.
29 An optional argument, the base config file name to look for. In this order, with later ones overriding earlier ones - 29 An optional argument, the base config file name to look for. In this order, with later ones overriding earlier ones -
30 defaults from the options table 30 defaults from the options table
@@ -34,7 +34,7 @@ _.parseArgs = function(options, args)
34]] 34]]
35 local o = nil 35 local o = nil
36 if 0 ~= #args then 36 if 0 ~= #args then
37 for i,a in pairs(args) do 37 for i,a in ipairs(args) do
38 local s, e = a:find("=") 38 local s, e = a:find("=")
39 if nil == s then e = 0 end 39 if nil == s then e = 0 end
40 opt = a:sub(1, e - 1) 40 opt = a:sub(1, e - 1)
@@ -51,7 +51,7 @@ _.parseArgs = function(options, args)
51 for k, v in pairs(options) do 51 for k, v in pairs(options) do
52 h = h .. k .. ' | ' 52 h = h .. k .. ' | '
53 end 53 end
54 print('Usage: aataaj.lua {' .. string.sub(h, 1, -2) .. '}') 54 print('Usage: ' .. args[0] .. ' {' .. string.sub(h, 1, -2) .. '}')
55 os.exit(0) 55 os.exit(0)
56 end 56 end
57end 57end
diff --git a/aataaj.lua b/aataaj.lua
index 06077c2..6108dd5 100755
--- a/aataaj.lua
+++ b/aataaj.lua
@@ -143,8 +143,7 @@ local options =
143 ['--help'] = {help}, 143 ['--help'] = {help},
144} 144}
145 145
146local args = {...} 146_.parse(arg, options)
147_.parseArgs(options, args)
148 147
149 148
150 149
@@ -184,7 +183,7 @@ for i,l in ipairs(cards.lines) do
184 Cards[l]['devs'][n] = n 183 Cards[l]['devs'][n] = n
185 print("\tFound playback device " .. Cards[l].card - 1 .. " : " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['playbackDevs'][j] .. ' ' .. n) 184 print("\tFound playback device " .. Cards[l].card - 1 .. " : " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['playbackDevs'][j] .. ' ' .. n)
186 io.flush() 185 io.flush()
187 if 'JACK' ~= args[1] then 186 if 'JACK' ~= arg[1] then
188 print('\t\tALSA_CARD=' .. Cards[l].card - 1 .. ' ' .. speaker .. ' "Found playback device ' .. Cards[l].card - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"') 187 print('\t\tALSA_CARD=' .. Cards[l].card - 1 .. ' ' .. speaker .. ' "Found playback device ' .. Cards[l].card - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"')
189 io.flush() 188 io.flush()
190 end 189 end
@@ -221,7 +220,7 @@ print('')
221io.flush() 220io.flush()
222 221
223 222
224if 'start' == args[1] then 223if 'start' == arg[1] then
225 __('mkdir -p ' .. asoundrcPath):Do() 224 __('mkdir -p ' .. asoundrcPath):Do()
226 local a, e = io.open(asoundrcPath .. '/jack-plumbing', "w") 225 local a, e = io.open(asoundrcPath .. '/jack-plumbing', "w")
227 if nil == a then print("Could not open " .. asoundrcPath .. '/jack-plumbing') else 226 if nil == a then print("Could not open " .. asoundrcPath .. '/jack-plumbing') else
@@ -391,7 +390,7 @@ pcm.!default {
391 ]]) 390 ]])
392 a:close() 391 a:close()
393 end 392 end
394elseif 'JACK' == args[1] then 393elseif 'JACK' == arg[1] then
395 print('') 394 print('')
396 print("Start up JACK and friends.") 395 print("Start up JACK and friends.")
397 print("jack_control") 396 print("jack_control")
diff --git a/test_.lua b/test_.lua
index e4448d2..d29a433 100755
--- a/test_.lua
+++ b/test_.lua
@@ -55,8 +55,7 @@ local options =
55 ['--help'] = {help}, 55 ['--help'] = {help},
56} 56}
57 57
58local args = {...} 58_.parse(arg, options)
59_.parseArgs(options, args)
60 59
61 60
62 61
@@ -137,7 +136,12 @@ print(__'command NoSuchCommand':log():show():Do().status)
137--__'qpdfview':forkOnce() 136--__'qpdfview':forkOnce()
138--__'qpdfview':forkOnce() 137--__'qpdfview':forkOnce()
139 138
139print('')
140
141for i,a in ipairs(arg) do print('arg[' .. i .. '] = ' .. a) end
142print('')
143for k,a in pairs(arg) do print('arg[' .. k .. '] = ' .. a) end
140 144
141__'date':log():show():Do() 145__'date':log():show():Do()
142__'date; sleep 5; date':log():show():Do() 146__'date; sleep 5; date':log():show():Do()
143print('') 147