Mercurial > hg > octave-lyh
annotate scripts/miscellaneous/news.m @ 13863:b81e0b3fedab
news: support to read news of installed packages
author | Carnë Draug <carandraug+dev@gmail.com> |
---|---|
date | Thu, 03 Nov 2011 12:11:31 +0000 |
parents | e51ad94535b9 |
children | a03e96aa4977 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 John W. Eaton |
6252 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6252 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6252 | 18 |
19 ## -*- texinfo -*- | |
13863
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
20 ## @deftypefn {Function File} {} news (@var{package}) |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
21 ## Display the current NEWS file for Octave or installed package. |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
22 ## |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
23 ## If @var{package} is the name of an installed package, display the current |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
24 ## NEWS file for that package. |
6252 | 25 ## @end deftypefn |
26 | |
13863
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
27 function news (package) |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
28 |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
29 ## also let users specify 'octave' |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
30 if (nargin == 0 || (nargin == 1 && ischar (package) && strcmpi (package, "octave"))) |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
31 octetcdir = octave_config_info ("octetcdir"); |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
32 newsfile = fullfile (octetcdir, "NEWS"); |
6252 | 33 |
13863
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
34 elseif (nargin == 1 && ischar (package)) |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
35 installed = pkg ("list"); |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
36 names = cellfun (@(x) x.name, installed, "UniformOutput", false); |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
37 ## we are nice and let the user use any case on the package name |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
38 pos = strcmpi (names, package); |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
39 if (!any (pos)) |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
40 error ("Package '%s' is not installed.", package); |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
41 endif |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
42 newsfile = fullfile (installed{pos}.dir, "doc", "NEWS"); |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
43 |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
44 else |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
45 print_usage; |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
46 endif |
6252 | 47 |
48 if (exist (newsfile, "file")) | |
49 f = fopen (newsfile, "r"); | |
7769
247828ad21e2
Replace deprecated isstr() call
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
7016
diff
changeset
|
50 while (ischar (line = fgets (f))) |
8688
d7306ecd077a
news.m: use puts, not printf
John W. Eaton <jwe@octave.org>
parents:
7769
diff
changeset
|
51 puts (line); |
6252 | 52 endwhile |
53 else | |
13863
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
54 if (package) |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
55 error ("news: unable to locate NEWS file of %s package", package); |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
56 else |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
57 error ("news: unable to locate NEWS file"); |
b81e0b3fedab
news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents:
12844
diff
changeset
|
58 endif |
6252 | 59 endif |
60 | |
61 endfunction | |
12844
e51ad94535b9
codesprint: Remove news.m from test statistics.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
62 |
e51ad94535b9
codesprint: Remove news.m from test statistics.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
63 ## Remove from test statistics. No real tests possible |
e51ad94535b9
codesprint: Remove news.m from test statistics.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
64 %!assert (1) |