Mercurial > octave-nkf
annotate scripts/miscellaneous/ver.m @ 19630:0e1f5a750d00
maint: Periodic merge of gui-release to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 10:24:46 -0500 |
parents | 8a8a7bc2a09d 446c46af4b42 |
children | db92e7e28e1f |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
16491
diff
changeset
|
1 ## Copyright (C) 2005-2013 William Poetra Yoga Hadisoeseno |
5546 | 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. | |
5546 | 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/>. | |
5546 | 18 |
19 ## -*- texinfo -*- | |
19221 | 20 ## @deftypefn {Function File} {} ver |
21 ## @deftypefnx {Function File} {} ver Octave | |
22 ## @deftypefnx {Function File} {} ver @var{package} | |
23 ## @deftypefnx {Function File} {v =} ver (@dots{}) | |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
24 ## |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
25 ## Display a header containing the current Octave version number, license |
19221 | 26 ## string, and operating system. The header is followed by a list of installed |
27 ## packages, versions, and installation directories. | |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
28 ## |
19221 | 29 ## Use the package name @var{package} or Octave to limit the listing to a |
30 ## desired component. | |
16491
b10a23fe80bb
doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents:
16489
diff
changeset
|
31 ## |
19221 | 32 ## When called with an output argument, return a vector of structures |
33 ## describing Octave and each installed package. The structure includes the | |
34 ## following fields. | |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
35 ## |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
36 ## @table @code |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
37 ## @item Name |
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
38 ## Package name. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
39 ## |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
40 ## @item Version |
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
41 ## Version of the package. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
42 ## |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
43 ## @item Revision |
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
44 ## Revision of the package. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
45 ## |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
46 ## @item Date |
16491
b10a23fe80bb
doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents:
16489
diff
changeset
|
47 ## Date of the version/revision. |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
48 ## @end table |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
49 ## |
19226
8a8a7bc2a09d
Improve docstrings and mark documentation m-files as tested in miscellaneous/ dir.
Rik <rik@octave.org>
parents:
19221
diff
changeset
|
50 ## @seealso{version, octave_config_info, usejava, pkg} |
5546 | 51 ## @end deftypefn |
52 | |
53 ## Author: William Poetra Yoga Hadisoeseno <williampoetra@gmail.com> | |
54 | |
19221 | 55 function retval = ver (package = "") |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
56 |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
57 if (nargin > 1) |
6046 | 58 print_usage (); |
5546 | 59 endif |
60 | |
19221 | 61 if (nargout == 0) |
62 [unm, err] = uname (); | |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
63 |
19221 | 64 if (err) |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
65 os_string = "unknown"; |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
66 else |
19221 | 67 os_string = sprintf ("%s %s %s %s", |
68 unm.sysname, unm.release, unm.version, unm.machine); | |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
69 endif |
5546 | 70 |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
71 hbar(1:70) = "-"; |
19221 | 72 desc = {hbar |
73 ["GNU Octave Version: " OCTAVE_VERSION] | |
74 ["GNU Octave License: " license] | |
75 ["Operating System: " os_string] | |
76 hbar}; | |
77 | |
78 printf ("%s\n", desc{:}); | |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
79 |
19221 | 80 if (isempty (package)) |
81 pkg ("list"); | |
82 elseif (strcmpi (package, "Octave")) | |
83 ## Nothing to do, Octave version was already reported | |
84 else | |
85 pkg ("list", package); | |
86 endif | |
5546 | 87 else |
19221 | 88 ## Get the installed packages |
89 if (isempty (package)) | |
90 lst = pkg ("list"); | |
91 ## Start with the version info for Octave | |
92 retval = struct ("Name", "Octave", "Version", version, | |
93 "Release", [], "Date", []); | |
94 for i = 1:numel (lst) | |
95 retval(end+1) = struct ("Name", lst{i}.name, "Version", lst{i}.version, | |
96 "Release", [], "Date", lst{i}.date); | |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
97 endfor |
19221 | 98 elseif (strcmpi (package, "Octave")) |
99 retval = struct ("Name", "Octave", "Version", version, | |
100 "Release", [], "Date", []); | |
101 else | |
102 lst = pkg ("list", package); | |
103 if (isempty (lst)) | |
104 retval = struct ("Name", "", "Version", [], | |
105 "Release", [], "Date", []); | |
106 else | |
107 retval = struct ("Name", lst{1}.name, "Version", lst{1}.version, | |
108 "Release", [], "Date", lst{1}.date); | |
109 endif | |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
110 endif |
5546 | 111 endif |
112 | |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
113 endfunction |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
114 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
115 |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
116 %!test |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
117 %! result = ver; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
118 %! assert (result(1).Name, "Octave"); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
119 %! assert (result(1).Version, version); |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
120 %! result = ver ("octave"); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
121 %! assert (result(1).Name, "Octave"); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
122 %! assert (result(1).Version, version); |
5546 | 123 |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
124 %!test |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
125 %! lst = pkg ("list"); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
126 %! for n = 1:numel (lst) |
7499
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
127 %! expected = lst{n}.name; |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
128 %! result = ver (expected); |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
129 %! assert (result.Name, expected); |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
130 %! assert (isfield (result, "Version"), true); |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
131 %! assert (isfield (result, "Release"), true); |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
132 %! assert (isfield (result, "Date"), true); |
94d0cdd60dda
Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
133 %! endfor |
5546 | 134 |