1 ## Copyright (C) 2005-2012 William Poetra Yoga Hadisoeseno
3 ## This file is part of Octave.
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.
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.
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/>.
20 ## @deftypefn {Function File} {} ver ()
21 ## Display a header containing the current Octave version number, license
22 ## string and operating system, followed by the installed package names,
23 ## versions, and installation directories.
25 ## @deftypefnx {Function File} {v =} ver ()
26 ## Return a vector of structures, respecting Octave and each installed package.
27 ## The structure includes the following fields.
34 ## Version of the package.
37 ## Revision of the package.
40 ## Date respecting the version/revision.
43 ## @deftypefnx {Function File} {v =} ver ("Octave")
44 ## Return version information for Octave only.
46 ## @deftypefnx {Function File} {v =} ver (@var{package})
47 ## Return version information for @var{package}.
49 ## @seealso{version, octave_config_info}
52 ## Author: William Poetra Yoga Hadisoeseno <williampoetra@gmail.com>
54 function varargout = ver (package = "")
60 ## Start with the version info for Octave
61 ret = struct ("Name", "Octave", "Version", version,
62 "Release", [], "Date", []);
64 ## Add the installed packages
66 for i = 1:length (lst)
67 ret(end+1) = struct ("Name", lst{i}.name, "Version", lst{i}.version,
68 "Release", [], "Date", lst{i}.date);
72 octave_license = license ();
74 [unm, status] = uname ();
77 os_string = "unknown";
79 os_string = sprintf ("%s %s %s %s", unm.sysname, unm.release,
80 unm.version, unm.machine);
84 ver_line1 = "GNU Octave Version ";
85 ver_line2 = "GNU Octave License: ";
86 ver_line3 = "Operating System: ";
88 ver_desc = sprintf ("%s\n%s%s\n%s%s\n%s%s\n%s\n", hbar, ver_line1, version,
89 ver_line2, octave_license, ver_line3, os_string, hbar);
95 if (! isempty (package))
98 if (strcmpi (ret(r).Name, package))
112 %! assert (result(1).Name, "Octave")
113 %! assert (result(1).Version, version)
114 %! result = ver ("octave");
115 %! assert (result(1).Name, "Octave")
116 %! assert (result(1).Version, version)
119 %! lst = pkg ("list");
120 %! for n=1:numel(lst)
121 %! expected = lst{n}.name;
122 %! result = ver (expected);
123 %! assert (result.Name, expected);
124 %! assert (isfield (result, "Version"), true);
125 %! assert (isfield (result, "Release"), true);
126 %! assert (isfield (result, "Date"), true);