aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordvs12024-10-25 17:03:00 +1000
committerdvs12024-10-25 17:03:00 +1000
commitf28129b5c96317a0486592011db8e02655b18e1a (patch)
treeca38e8d662dd33b58667825605dd10030b52b883
parentTurn on debug mode, or pretend to, this bit isn't functional yet. (diff)
downloadJackOnAllDevices-f28129b5c96317a0486592011db8e02655b18e1a.zip
JackOnAllDevices-f28129b5c96317a0486592011db8e02655b18e1a.tar.gz
JackOnAllDevices-f28129b5c96317a0486592011db8e02655b18e1a.tar.bz2
JackOnAllDevices-f28129b5c96317a0486592011db8e02655b18e1a.tar.xz
Help command now prints out full usage as well.
Diffstat (limited to '')
-rwxr-xr-x_.lua41
-rwxr-xr-xaataaj.lua2
-rwxr-xr-xtest_.lua2
3 files changed, 31 insertions, 14 deletions
diff --git a/_.lua b/_.lua
index 03761d2..945f4f2 100755
--- a/_.lua
+++ b/_.lua
@@ -28,14 +28,15 @@ C = function(s) print('CRITICAL ' .. s); io.flush() end
28 28
29local optionsCommon = 29local optionsCommon =
30{ 30{
31 help = {help = 'Print the help text', 31 help = {help = 'Print the help text.',
32 func = function(self, a, args, i) 32 func = function(self, options, a, args, i)
33 print(Help) 33 print(Help)
34 _.usage(args, options, true)
34 os.exit(0) 35 os.exit(0)
35 end 36 end
36 }, 37 },
37 ['--version'] = {help = 'Print the version details.', 38 ['--version'] = {help = 'Print the version details.',
38 func = function(self, a, args, i) 39 func = function(self, options, a, args, i)
39 print('This is version ' ..Version .. ' of ' .. args[0]) 40 print('This is version ' ..Version .. ' of ' .. args[0])
40 os.exit(0) 41 os.exit(0)
41 end 42 end
@@ -43,6 +44,29 @@ local optionsCommon =
43} 44}
44optionsCommon['--help'] = optionsCommon['help'] 45optionsCommon['--help'] = optionsCommon['help']
45 46
47_.usage = function(args, options, all)
48 local h = ''
49 for k, v in pairs(options) do
50 if 'table' == type(v) then h = h .. k .. ' | ' end
51 end
52 for k, v in pairs(optionsCommon) do
53 if 'table' == type(v) then h = h .. k .. ' | ' end
54 end
55 print('Usage: ' .. args[0] .. ' {' .. string.sub(h, 1, -2) .. '}')
56 if true == all then
57 for k, v in pairs(options) do
58 if 'table' == type(v) then
59 if nil ~= v.help then print(k .. '\t\t' .. v.help) end
60 end
61 end
62 for k, v in pairs(optionsCommon) do
63 if 'table' == type(v) then
64 if nil ~= v.help then print(k .. '\t\t' .. v.help) end
65 end
66 end
67 end
68end
69
46_.parse = function(args, options, confFile) 70_.parse = function(args, options, confFile)
47 local o = nil 71 local o = nil
48 72
@@ -51,7 +75,7 @@ _.parse = function(args, options, confFile)
51 if nil == o then o = optionsCommon[name] end 75 if nil == o then o = optionsCommon[name] end
52 if nil ~= o then 76 if nil ~= o then
53 if nil ~= val then o.value = val; D(name .. ' = ' .. tostring(val)) end 77 if nil ~= val then o.value = val; D(name .. ' = ' .. tostring(val)) end
54 if nil ~= o.func then o:func(a, args, i) end 78 if nil ~= o.func then o:func(options, a, args, i) end
55 end 79 end
56 return o 80 return o
57 end 81 end
@@ -85,14 +109,7 @@ _.parse = function(args, options, confFile)
85 end 109 end
86 110
87 if nil == o then 111 if nil == o then
88 local h = '' 112 _.usage(args, options)
89 for k, v in pairs(options) do
90 if 'table' == type(v) then h = h .. k .. ' | ' end
91 end
92 for k, v in pairs(optionsCommon) do
93 if 'table' == type(v) then h = h .. k .. ' | ' end
94 end
95 print('Usage: ' .. args[0] .. ' {' .. string.sub(h, 1, -2) .. '}')
96 os.exit(0) 113 os.exit(0)
97 end 114 end
98end 115end
diff --git a/aataaj.lua b/aataaj.lua
index aa2829d..6f840f3 100755
--- a/aataaj.lua
+++ b/aataaj.lua
@@ -107,7 +107,7 @@ local options =
107 STOP = 107 STOP =
108 { 108 {
109 help = 'Command to stop the JACK stuff, for users.', 109 help = 'Command to stop the JACK stuff, for users.',
110 func = function(self, a, args, i) 110 func = function(self, options, a, args, i)
111 _.killEmAll{'qsynth'} 111 _.killEmAll{'qsynth'}
112 __[[#!/bin/bash 112 __[[#!/bin/bash
113 a2j_control --stop 113 a2j_control --stop
diff --git a/test_.lua b/test_.lua
index e4ebcc8..b1ded7d 100755
--- a/test_.lua
+++ b/test_.lua
@@ -21,7 +21,7 @@ local options =
21 stop = {help = 'Command to stop the scanning process, for Sys V init.',}, 21 stop = {help = 'Command to stop the scanning process, for Sys V init.',},
22 JACK = {help = 'Command to start the JACK stuff, for users.',}, 22 JACK = {help = 'Command to start the JACK stuff, for users.',},
23 STOP = {help = 'Command to stop the JACK stuff, for users.', 23 STOP = {help = 'Command to stop the JACK stuff, for users.',
24 func = function(self, a, args, i) 24 func = function(self, options, a, args, i)
25--[=[ 25--[=[
26 _.killEmAll{'qsynth'} 26 _.killEmAll{'qsynth'}
27 __[[ 27 __[[