Mercurial > repos > public > matlab_path_manager
changeset 7:309cc6c0cd75
Change names in ui
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 10 Sep 2018 17:05:03 +0200 |
parents | 19c4af287596 |
children | f37b4c00a863 |
files | +mpm/check.m +mpm/checkin.m +mpm/checkout.m +mpm/leave.m +mpm/set.m +mpm/verify.m |
diffstat | 6 files changed, 66 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/+mpm/check.m Mon Sep 10 16:54:29 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -% Check if the current proejct settings are correct -% The right version is in the path -% The right version is at the top of the path -% -% Useful to put at the top of some scripts -function check() - if ~exist('d', 'var') || isempty(d) - d = ''; - end - - folders = split(path(), pathsep); - - sp = mpm.subpaths(d); - for i = 1:length(sp) - if ~isAtTop(sp{i}, fullfile(pwd, sp{i}), folders) - error('Subpaths are not correctly set. Try running mpm.set()'); - end - end -end - -function b = isAtTop(subpath, fullsubpath, paths) - for i = 1:length(paths) - if ~endsWith(paths{i}, subpath) - continue - end - - b = strcmp(fullsubpath, paths{i}); - return - end - - b = false; -end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/+mpm/checkin.m Mon Sep 10 17:05:03 2018 +0200 @@ -0,0 +1,17 @@ +% Set project to current folder +function set(d) + if ~exist('d', 'var') || isempty(d) + d = ''; + end + + state = mpm.load_state(); + + sp = mpm.subpaths(d); + for i = 1:length(sp) + subpath = fullfile(pwd, sp{i}); + addpath(subpath); + state.added_paths(subpath) = true; + end + + mpm.save_state(state); +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/+mpm/checkout.m Mon Sep 10 17:05:03 2018 +0200 @@ -0,0 +1,17 @@ +% Leave project in current folder +function leave(d) + if ~exist('d', 'var') || isempty(d) + d = ''; + end + + state = mpm.load_state(); + + sp = mpm.subpaths(d); + for i = 1:length(sp) + subpath = fullfile(pwd, sp{i}); + rmpath(subpath); + state.added_paths.remove(subpath); + end + + mpm.save_state(state); +end
--- a/+mpm/leave.m Mon Sep 10 16:54:29 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -% Leave project in current folder -function leave(d) - if ~exist('d', 'var') || isempty(d) - d = ''; - end - - state = mpm.load_state(); - - sp = mpm.subpaths(d); - for i = 1:length(sp) - subpath = fullfile(pwd, sp{i}); - rmpath(subpath); - state.added_paths.remove(subpath); - end - - mpm.save_state(state); -end
--- a/+mpm/set.m Mon Sep 10 16:54:29 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -% Set project to current folder -function set(d) - if ~exist('d', 'var') || isempty(d) - d = ''; - end - - state = mpm.load_state(); - - sp = mpm.subpaths(d); - for i = 1:length(sp) - subpath = fullfile(pwd, sp{i}); - addpath(subpath); - state.added_paths(subpath) = true; - end - - mpm.save_state(state); -end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/+mpm/verify.m Mon Sep 10 17:05:03 2018 +0200 @@ -0,0 +1,32 @@ +% Check if the current proejct settings are correct +% The right version is in the path +% The right version is at the top of the path +% +% Useful to put at the top of some scripts +function check() + if ~exist('d', 'var') || isempty(d) + d = ''; + end + + folders = split(path(), pathsep); + + sp = mpm.subpaths(d); + for i = 1:length(sp) + if ~isAtTop(sp{i}, fullfile(pwd, sp{i}), folders) + error('Subpaths are not correctly set. Try running mpm.set()'); + end + end +end + +function b = isAtTop(subpath, fullsubpath, paths) + for i = 1:length(paths) + if ~endsWith(paths{i}, subpath) + continue + end + + b = strcmp(fullsubpath, paths{i}); + return + end + + b = false; +end