|
6 | 6 | % "labkit_Example_app", varargin, nargout); |
7 | 7 | % [handled, outputs, debug] = labkit.ui.app.dispatchRequest( ... |
8 | 8 | % "labkit_Example_app", varargin, nargout, "Requirements", req); |
| 9 | +% [handled, outputs, debug] = labkit.ui.app.dispatchRequest( ... |
| 10 | +% "labkit_Example_app", varargin, nargout, ... |
| 11 | +% "Requirements", req, "Version", info); |
9 | 12 | % |
10 | 13 | % Inputs: |
11 | 14 | % appName - app entry-point name used to build app-scoped error IDs. |
12 | 15 | % args - input argument cell from the app entry point. |
13 | 16 | % nout - requested output count from the app entry point. |
14 | 17 | % Name-value options: |
15 | 18 | % Requirements - optional struct returned by app requirements(). |
| 19 | +% Version - optional struct returned by app version(). |
16 | 20 | % |
17 | 21 | % Outputs: |
18 | | -% handled - true only when the lightweight "requirements" request is |
19 | | -% consumed; false for normal and debug launches. |
20 | | -% outputs - one-cell output containing the requirements struct for the |
21 | | -% "requirements" request; empty otherwise. |
| 22 | +% handled - true only when a lightweight request such as "requirements" or |
| 23 | +% "version" is consumed; false for normal and debug launches. |
| 24 | +% outputs - one-cell output containing the requested app struct for handled |
| 25 | +% lightweight requests; empty otherwise. |
22 | 26 | % debugContext - disabled for normal launches; enabled for "debug" launches. |
23 | 27 | % Debug launch requests do not consume app launch. Public app debug |
24 | 28 | % launches write a trace log under artifacts/debug so the last event is |
|
54 | 58 | return; |
55 | 59 | end |
56 | 60 |
|
| 61 | + if request == "version" |
| 62 | + if nout > 1 |
| 63 | + error(errorId(appName, 'TooManyOutputs'), ... |
| 64 | + '%s version request returns at most one output.', appName); |
| 65 | + end |
| 66 | + if numel(args) > 1 |
| 67 | + error(errorId(appName, 'UnsupportedInput'), ... |
| 68 | + '%s version request does not accept options.', appName); |
| 69 | + end |
| 70 | + handled = true; |
| 71 | + outputs = {options.Version}; |
| 72 | + return; |
| 73 | + end |
| 74 | + |
57 | 75 | if isDebugRequest(request) |
58 | 76 | if nout > 2 |
59 | 77 | error(errorId(appName, 'TooManyOutputs'), ... |
|
79 | 97 | end |
80 | 98 |
|
81 | 99 | function options = parseOptions(varargin) |
82 | | - options = struct('Requirements', []); |
| 100 | + options = struct('Requirements', [], 'Version', []); |
83 | 101 | if isempty(varargin) |
84 | 102 | return; |
85 | 103 | end |
|
92 | 110 | switch name |
93 | 111 | case "Requirements" |
94 | 112 | options.Requirements = varargin{k + 1}; |
| 113 | + case "Version" |
| 114 | + options.Version = varargin{k + 1}; |
95 | 115 | otherwise |
96 | 116 | error('labkit:ui:app:InvalidDispatchOptions', ... |
97 | 117 | 'Unsupported dispatch option "%s".', name); |
|
0 commit comments