Skip to content

Commit dc1fc60

Browse files
committed
force required number of save creds/config inputs
1 parent 537e3f8 commit dc1fc60

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

plotly/plotly_user_aux/saveplotlyconfig.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain)
33
% Plotly config info are saved as JSON strings
44
% in ~/.plotly/.config
55

6+
% catch missing input arguments
7+
if nargin < 1
8+
error('plotly:saveconfig', ...
9+
['Incorrect number of inputs. Please save your configuration ', ...
10+
'as follows: >> saveplotlyconfig(plotly_domain,', ...
11+
'[optional]plotly_streaming_domain)']);
12+
end
13+
614
% if the config file exists, then load it up
715
try
816
config = loadplotlyconfig();

plotly/plotly_user_aux/saveplotlycredentials.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ function saveplotlycredentials(username, api_key, stream_ids)
33
% Plotly credentials are saved as JSON strings
44
% in ~/.plotly/.credentials
55

6+
% catch missing input arguments
7+
if nargin < 2
8+
error('plotly:savecredentials', ...
9+
['Incorrect number of inputs. Please save your credentials ', ...
10+
'as follows: >> saveplotlycredentials(username, api_key,', ...
11+
'[optional]stream_ids)']);
12+
end
13+
614
% if the credentials file exists, then load it up
715
try
816
creds = loadplotlycredentials();
@@ -45,9 +53,6 @@ function saveplotlycredentials(username, api_key, stream_ids)
4553
creds.username = username;
4654
creds.api_key = api_key;
4755
creds.stream_ids = stream_ids;
48-
otherwise %need to specify both the username and api_key
49-
error('plotly:savecredentials',...
50-
'Please specify your username and api_key');
5156
end
5257

5358
creds_string = m2json(creds);

0 commit comments

Comments
 (0)