]> Creatis software - CreaPhase.git/blob - octave_packages/m/miscellaneous/news.m
update packages
[CreaPhase.git] / octave_packages / m / miscellaneous / news.m
1 ## Copyright (C) 2007-2012 John W. Eaton
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} news (@var{package})
21 ## Display the current NEWS file for Octave or installed package.
22 ##
23 ## If @var{package} is the name of an installed package, display the current
24 ## NEWS file for that package.
25 ## @end deftypefn
26
27 function news (package = "octave")
28
29   if (ischar (package) && strcmpi (package, "octave"))
30     octetcdir = octave_config_info ("octetcdir");
31     newsfile  = fullfile (octetcdir, "NEWS");
32
33   elseif (nargin == 1 && ischar (package))
34     installed = pkg ("list");
35     names     = cellfun (@(x) x.name, installed, "UniformOutput", false);
36     ## we are nice and let the user use any case on the package name
37     pos = strcmpi (names, package);
38     if (!any (pos))
39       error ("Package '%s' is not installed.", package);
40     endif
41     newsfile = fullfile (installed{pos}.dir, "packinfo", "NEWS");
42
43   else
44     print_usage;
45   endif
46
47   if (exist (newsfile, "file"))
48     f = fopen (newsfile, "r");
49     while (ischar (line = fgets (f)))
50       puts (line);
51     endwhile
52   else
53     if (strcmpi (package, "octave"))
54       error ("news: unable to locate NEWS file");
55     else
56       error ("news: unable to locate NEWS file of %s package", package);
57     endif
58   endif
59
60 endfunction
61
62 ## Remove from test statistics.  No real tests possible
63 %!assert (1)