summaryrefslogtreecommitdiffstats
path: root/doc/package.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/package.n')
-rw-r--r--doc/package.n34
1 files changed, 26 insertions, 8 deletions
diff --git a/doc/package.n b/doc/package.n
index dd1fc36..07a3d47 100644
--- a/doc/package.n
+++ b/doc/package.n
@@ -12,7 +12,7 @@
package \- Facilities for package loading and version control
.SH SYNOPSIS
.nf
-\fBpackage forget ?\fIpackage package ...\fR?
+\fBpackage forget\fR ?\fIpackage package ...\fR?
\fBpackage ifneeded \fIpackage version\fR ?\fIscript\fR?
\fBpackage names\fR
\fBpackage present \fIpackage \fR?\fIrequirement...\fR?
@@ -27,7 +27,6 @@ package \- Facilities for package loading and version control
\fBpackage prefer \fR?\fBlatest\fR|\fBstable\fR?
.fi
.BE
-
.SH DESCRIPTION
.PP
This command keeps a simple database of the packages available for
@@ -44,12 +43,14 @@ primarily by system scripts that maintain the package database.
The behavior of the \fBpackage\fR command is determined by its first argument.
The following forms are permitted:
.TP
-\fBpackage forget ?\fIpackage package ...\fR?
+\fBpackage forget\fR ?\fIpackage package ...\fR?
+.
Removes all information about each specified package from this interpreter,
including information provided by both \fBpackage ifneeded\fR and
\fBpackage provide\fR.
.TP
\fBpackage ifneeded \fIpackage version\fR ?\fIscript\fR?
+.
This command typically appears only in system configuration
scripts to set up the package database.
It indicates that a particular version of
@@ -71,6 +72,7 @@ or an empty string if no \fBpackage ifneeded\fR command has
been invoked for this \fIpackage\fR and \fIversion\fR.
.TP
\fBpackage names\fR
+.
Returns a list of the names of all packages in the
interpreter for which a version has been provided (via
\fBpackage provide\fR) or for which a \fBpackage ifneeded\fR
@@ -83,6 +85,7 @@ This command is equivalent to \fBpackage require\fR except that it
does not try and load the package if it is not already loaded.
.TP
\fBpackage provide \fIpackage \fR?\fIversion\fR?
+.
This command is invoked to indicate that version \fIversion\fR
of package \fIpackage\fR is now present in the interpreter.
It is typically invoked once as part of an \fBifneeded\fR script,
@@ -94,7 +97,8 @@ returns the version number that is currently provided, or an
empty string if no \fBpackage provide\fR command has been
invoked for \fIpackage\fR in this interpreter.
.TP
-\fBpackage require\fR \fIpackage \fR?\fIrequirement...\fR?
+\fBpackage require \fR\fIpackage \fR?\fIrequirement...\fR?
+.
This command is typically invoked by Tcl code that wishes to use
a particular version of a particular package. The arguments
indicate which package is wanted, and the command ensures that
@@ -140,11 +144,13 @@ package, then the command returns an error.
.RE
.TP
\fBpackage require \-exact \fIpackage version\fR
+.
This form of the command is used when only the given \fIversion\fR
of \fIpackage\fR is acceptable to the caller. This command is
equivalent to \fBpackage require \fIpackage version\fR-\fIversion\fR.
.TP
\fBpackage unknown \fR?\fIcommand\fR?
+.
This command supplies a
.QW "last resort"
command to invoke during
@@ -166,30 +172,36 @@ If \fIcommand\fR is specified as an empty string, then the current
\fBpackage unknown\fR script is removed, if there is one.
.TP
\fBpackage vcompare \fIversion1 version2\fR
+.
Compares the two version numbers given by \fIversion1\fR and \fIversion2\fR.
Returns -1 if \fIversion1\fR is an earlier version than \fIversion2\fR,
-0 if they are equal, and 1 if \fIversion1\fR is later than \fBversion2\fR.
+0 if they are equal, and 1 if \fIversion1\fR is later than \fIversion2\fR.
.TP
\fBpackage versions \fIpackage\fR
+.
Returns a list of all the version numbers of \fIpackage\fR
for which information has been provided by \fBpackage ifneeded\fR
commands.
.TP
\fBpackage vsatisfies \fIversion requirement...\fR
+.
Returns 1 if the \fIversion\fR satisfies at least one of the given
requirements, and 0 otherwise. Each \fIrequirement\fR is allowed to
have any of the forms:
.RS
.TP
min
+.
This form is called
.QW min-bounded .
.TP
min-
+.
This form is called
.QW min-unbound .
.TP
min-max
+.
This form is called
.QW bounded .
.RE
@@ -328,8 +340,10 @@ Once you have done this, packages will be loaded automatically
in response to \fBpackage require\fR commands.
See the documentation for \fBpkg_mkIndex\fR for details.
.SH EXAMPLES
+.PP
To state that a Tcl script requires the Tk and http packages, put this
at the top of the script:
+.PP
.CS
\fBpackage require\fR Tk
\fBpackage require\fR http
@@ -338,15 +352,19 @@ at the top of the script:
To test to see if the Snack package is available and load if it is
(often useful for optional enhancements to programs where the loss of
the functionality is not critical) do this:
+.PP
.CS
if {[catch {\fBpackage require\fR Snack}]} {
- # Error thrown - package not found.
- # Set up a dummy interface to work around the absence
+ # Error thrown - package not found.
+ # Set up a dummy interface to work around the absence
} else {
- # We have the package, configure the app to use it
+ # We have the package, configure the app to use it
}
.CE
.SH "SEE ALSO"
msgcat(n), packagens(n), pkgMkIndex(n)
.SH KEYWORDS
package, version
+'\" Local Variables:
+'\" mode: nroff
+'\" End: