如何实现 TCL 包

如何实现 TCL 包

我正在尝试为 tcl/wish 程序编写一个参数解析器。

我正在研究https://stackoverflow.com/questions/24341141/package-for-parsing-argument-in-tclgetopts它建议使用通过包实现的实现,但我在第一个障碍面前就失败了。

他们建议使用命令package require cmdline,但我收到错误消息can't find package cmdline。我正在使用“Ubuntu 22.04.1 LTS”,安装程序安装了 TCL。

我不清楚包裹是否丢失,或者我是否写错了。

为什么会发生这种情况?我该如何解决?

我曾尝试使用其他人的代码作为内联过程,但这对我来说还没有作用!

戴夫

在明确操作系统版本后,我做了apt cache show tcl

$ apt-cache show tcl
Package: tcl
Architecture: amd64
Version: 8.6.11+1build2
Multi-Arch: foreign
Priority: optional
Section: interpreters
Source: tcltk-defaults
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian Tcl/Tk Packagers <[email protected]>

答案1

你不需要自己实现这个包——cmdline 是作为 Ubuntu 的一部分提供的包裹:

$ apt show tcllib
Package: tcllib
Version: 1.20+dfsg-1
Priority: optional
Section: universe/interpreters
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Tcl/Tk Debian Packagers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 21.8 MB
Depends: tcl (>= 8.6.0-2), iproute2 | freebsd-net-tools | hurd
Suggests: tcllib-critcl
Homepage: https://core.tcl.tk/tcllib/home
Download-Size: 4457 kB
APT-Sources: http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
Description: Standard Tcl Library
 Tcllib, the standard Tcl library, is a collection of common utility
 functions and modules all written in high-level Tcl.
 .
 Modules included:
   * aes: advanced encryption standard
   * amazon-s3: Amazon S3 web service interface
   * asn: an ASN.1 encoder and decoder
   * base32: a base32 encoder and decoder
   * base64: a base64 encoder and decoder
   * bee: bittorrent serialization encoder and decoder
   * bench: benchmark tool
   * bibtex: parser for bibliographies in BibTeX format
   * blowfish: blowfish encryption
   * cache: asynchronous in-memory cache
   * clay: clay framework
   * clock: date/time utilities
   * cmdline: a command line argument processor similar to opt
   * comm: remote communications facility
   * control: procedures for control flow structures
   * coroutine: coroutine utilities
   * counter: provides a counter facility and can compute statistics
     and histograms over the collected data.
   * crc: checksum-calculation routines (crc32, cksum, sum)
   * cron: automating the period callback of commands
   * csv: functions to handle CSV (comma-separated values) data
   * debug: debug messages infrastructure
   * defer: deferred execution
   * des: DES and 3DES encryption
   * dicttool: dictionary tools
   * dns: DNS and resolver library-related functions
   * docstrip: tools for literate programming, often used with (La)TeX
   * doctools: documentation tools
   * dtplite: lightweight doctools markup processor
   * fileutil: Tcl implementations of some standard Unix utilities
   * ftp: Tcl interface to the FTP protocol
   * ftpd: implementation of functions needed for an FTP server
   * fumagic: file utilities
   * generator: Tcl generator commands
   * gpx: GPS eXchange Format (GPX)
   * grammar_aycock: Aycock-Horspool-Earley parser generator for Tcl
   * grammar_fa: finite automaton operations and usage
   * grammar_me: grammar operations and usage
   * grammar_peg: grammar operations and usage
   * hook: hooks
   * html: generate and control HTML tags
   * htmlparse: parse HTML strings
   * http: HTTP protocol helper modules
   * httpd: HTTP server
   * httpwget: tool to download files over HTTP
   * ident: client interface to the ident protocol
   * imap4: IMAP client
   * inifile: parsing of Windows INI files
   * interp: interpreter utilities
   * irc: low-level IRC protocol interface
   * javascript: Tcl shortcuts to create common javascript functions
   * jpeg: functions to query and modify JPEG images
   * json: JSON parser
   * lambda: utility commands for anonymous procedures
   * lazyset: lazy evaluation for variables and arrays
   * ldap: LDAP client and extended object interface
   * log: functions to log messages with various facilities and levels
   * map: mapping utilities
   * mapproj: map projection routines
   * markdown: Markdown processor
   * math: Tcl math library
   * md4: md4 hashing functions
   * md5: md5 hashing functions
   * md5crypt: md5 based password hashing
   * mime: a MIME encoder and decoder
   * multiplexer: message multiplexing
   * namespacex: namespace utility commands
   * ncgi: a new CGI processing module
   * nettool: tools for networked applications
   * nmea: NMEA protocol implementation
   * nns: name service facility
   * nntp: Tcl functions for the NNTP protocol
   * ntp: functions for an NTP client
   * oauth: oauth API base signature
   * oodialect: build TclOO based DSLs
   * oometa: data registry service for TclOO classes
   * ooutil: utility commands for TclOO
   * otp: RFC 2289 a one-time password system
   * page: parser generator
   * pki: RSA public key encryption
   * pluginmgr: plugin management
   * png: functions to query and modify PNG images
   * pop3: a POP3 protocol implementation
   * pop3d: a POP3 server implementation
   * practcl: tool for integrating large modules for C API Tcl code
     that requires custom Tcl types and TclOO objects
   * processman: manage child processes
   * profiler: a function level Tcl source code profiler
   * pt: parser tools
   * rc4: implementation of the RC4 stream cipher
   * rcs: RCS low level utilities
   * report: provides objects which can be used to generate and format
     reports
   * rest: a framework for RESTful web services
   * ripemd: RIPEMD message-digest algorithm
   * sasl: Simple Authentication and Security Layer implementation
   * sha1: sha1 hashing functions
   * simulation: Tcl simulation tools
   * smtpd: implementation of functions needed for an SMTP server
   * snit: snit's not incr Tcl, OO system
   * soundex: comparison of words based on their phonetic likeness
   * stooop: simple Tcl-only object oriented programming scheme -
     provides C++/Java-like OOP interfaces
   * string: tokenize strings
   * stringprep: preparation of internationalized strings
   * struct: Tcl implementations of common data structures (tree, graph,
     etc)
   * tar: functions to manipulate tar files
   * tepam: Tcl's enhanced procedure and argument manager
   * term: terminal control
   * textutil: string manipulation library
   * tie: framework for creating persistent Tcl arrays
   * tiff: TIFF image manipulation
   * tool: dictionary tools
   * tool::datatype: dictionary tools
   * tool-ui: abstractions to allow Tao to express Native Tk, HTML5, and
     Tao-Layout interfaces
   * transfer: data transfer facilities
   * treeql: tree query language
   * try: trap and process errors and exceptions
   * udpcluster: UDP peer-to-peer cluster
   * uev: user events
   * units: convert and manipulate quantities with units
   * uri: functions to generate and manipulate commonly-used URIs
   * uuid: generator of universally unique identifiers (UUID)
   * valtype: validation types
   * virtchannel: reflected/virtual channel support
   * websocket: implementation of the websocket protocol
   * wip: word interpreter
   * yaml: YAML format encoder/decoder
   * zip: working with zip archives

如果您还没有启用 Universe 存储库,则需要启用它。

相关内容