diff --git a/README.md b/README.md index fef285d..22e0dfd 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ Download/clone this repo and add it to your Matlab path (using `addpath`). Now t - `mpm install [package-name]`: install package by name - `mpm uninstall [package-name]`: remove package, if installed -- `mpm search [package-name]`: find url given package name +- `mpm search [package-name]`: search for package given name (checks Github and Matlab File Exchange) - `mpm freeze`: lists all packages currently installed -- `mpm init`: adds all installed packages to path (for running on Matlab startup) +- `mpm init`: adds all installed packages to path (run when Matlab starts up) ## More details diff --git a/mpm.m b/mpm.m index 193179a..4543e22 100644 --- a/mpm.m +++ b/mpm.m @@ -86,7 +86,7 @@ function mpm(action, varargin) % find url if not set if isempty(pkg.url) pkg.url = findUrl(pkg, opts); - else % checks for .git and replaces + else pkg.url = handleCustomUrl(pkg.url); end @@ -184,13 +184,19 @@ function listPackages(opts) end function url = handleCustomUrl(url) -% if .git url, must remove and add /zipball/master + + % if .git url, must remove and add /zipball/master inds = strfind(url, '.git'); if isempty(inds) - return; + inds = strfind(url, '?download=true'); + if isempty(inds) + url = [url '?download=true']; + return; + end end ind = inds(end); url = [url(1:ind-1) '/zipball/master' url(ind+4:end)]; + end function url = findUrl(pkg, opts) @@ -661,7 +667,7 @@ function readRequirementsFile(fnm, opts) error('Cannot set --nopaths because it is in infile.'); end if ~isempty(line) - cmd = [line ' --installdir ' opts.installdir]; + cmd = [line ' installdir ' opts.installdir]; if opts.force cmd = [cmd ' --force']; end @@ -675,7 +681,7 @@ function readRequirementsFile(fnm, opts) % verify disp('About to run the following commands: '); for ii = 1:numel(cmds) - disp([' mpm2 ' opts.action ' ' cmds{ii}]); + disp([' mpm ' opts.action ' ' cmds{ii}]); end reply = input('Confirm (y/n)? ', 's'); if isempty(reply) @@ -688,6 +694,7 @@ function readRequirementsFile(fnm, opts) % run all for ii = 1:numel(cmds) - mpm(opts.action, cmds{ii}); + cmd = strsplit(cmds{ii}); + mpm(opts.action, cmd{:}); end end