Skip to content

Commit eab0ad2

Browse files
implementation of auto option
1 parent 3d3d64a commit eab0ad2

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

contribute.m

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function contribute(repoName, printLevel)
1+
function contribute(repoName, printLevel, autoOption)
22
% devTools
33
%
44
% PURPOSE: displays a menu and calls the respective subfunctions
@@ -7,11 +7,14 @@ function contribute(repoName, printLevel)
77
% 2. Select an existing feature (branch) to work on.
88
% 3. Publish a feature (branch).
99
% 4. Delete a feature (branch).
10+
% 5. Update the fork
1011
%
1112
% INPUT:
1213
%
14+
% repoName: Name of the repository (default: opencobra/cobratoolbox)
1315
% printLevel: 0: minimal printout (default)
1416
% 1: detailed printout (debug mode)
17+
% autoOption: menu option
1518

1619
global gitConf
1720
global gitCmd
@@ -26,16 +29,31 @@ function contribute(repoName, printLevel)
2629
% adding the src folder of the devTools
2730
addpath(genpath(fileparts(which(mfilename))));
2831

32+
% check the automatic option argument
33+
if exist('autoOption', 'var')
34+
if ~isempty(autoOption)
35+
if autoOption > 0 && autoOption < 6
36+
autoOptionFlag = true;
37+
else
38+
error('Please enter an automatic menu option between 1 and 5.')
39+
end
40+
end
41+
else
42+
autoOptionFlag = false;
43+
end
44+
2945
% treatment of input arguments
30-
if ~exist('repoName', 'var')
46+
if ~exist('repoName', 'var') || isempty(repoName)
3147
DEFAULTREPONAME = 'opencobra/cobratoolbox'; % set the default repository
3248
repoName = DEFAULTREPONAME;
3349
end
3450

3551
% soft reset if the repository name is different
3652
if ~isempty(gitConf)
37-
if ~strcmpi(repoName, [gitConf.remoteUserName '/' gitConf.remoteRepoName])
38-
resetDevTools();
53+
if isfield(gitConf, 'remoteUserName') && isfield(gitConf, 'remoteRepoName')
54+
if exist('repoName', 'var') && ~strcmpi(repoName, [gitConf.remoteUserName '/' gitConf.remoteRepoName])
55+
resetDevTools();
56+
end
3957
end
4058
end
4159

@@ -58,9 +76,12 @@ function contribute(repoName, printLevel)
5876

5977
fprintf(gitConf.launcher);
6078

61-
choice = input('\n (You can abort any process using CTRL+C)\n\n [1] Start a new feature (branch).\n [2] Select an existing feature (branch) to work on.\n [3] Publish a feature (branch).\n [4] Delete a feature (branch).\n [5] Update the fork.\n\n -> Please select what you want to do (enter the number): ', 's');
62-
63-
choice = str2num(choice);
79+
if autoOptionFlag
80+
choice = autoOption;
81+
else
82+
choice = input('\n (You can abort any process using CTRL+C)\n\n [1] Start a new feature (branch).\n [2] Select an existing feature (branch) to work on.\n [3] Publish a feature (branch).\n [4] Delete a feature (branch).\n [5] Update the fork.\n\n -> Please select what you want to do (enter the number): ', 's');
83+
choice = str2num(choice);
84+
end
6485

6586
if length(choice) == 0 || choice > 5 || choice < 0
6687
error('Please enter a number between 1 and 5.')

0 commit comments

Comments
 (0)