-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmjsIncludeEnvironmentProfile.m
38 lines (34 loc) · 1.18 KB
/
mjsIncludeEnvironmentProfile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function arguments = mjsIncludeEnvironmentProfile(varargin)
% Merge the given varargin with a named environment profile, if any.
%
% arguments = mjsIncludeEnvironmentProfile(varargin) scans the given
% varargin for a parameter named 'profile'. If found, loads the
% environment profile with that name and returns an argument struct
% that includes the profile as well as the given varargin.
%
% If varargin contains no 'profile' parameter, or if the named profile
% isn't found, returns the an argument struct with just the name-value
% pairs from the given varargin.
%
% arguments = mjsIncludeEnvironmentProfile(varargin)
%
% 2016-2017 Brainard Lab, University of Pennsylvania
parser = inputParser();
parser.KeepUnmatched = true;
parser.StructExpand = true;
parser.addParameter('profile', '', @ischar);
parser.parse(varargin{:});
profileName = parser.Results.profile;
%% Check for a named profile.
if isempty(profileName)
arguments = parser.Unmatched;
return;
end
profile = mjsGetEnvironmentProfile(profileName);
if isempty(profile)
arguments = parser.Unmatched;
return;
end
%% Merge the profile wiht the given arguments.
parser.parse(profile, varargin{:});
arguments = parser.Unmatched;