I am trying to write an argument parser for a tcl/wish program.

I am working through the examples on https://stackoverflow.com/questions/24341141/package-for-parsing-argument-in-tcl which suggests using an implementation of getopts via a package, yet I fall at the first hurdle.

They recommend using the command package require cmdline, I get the error message can't find package cmdline. I am using "Ubuntu 22.04.1 LTS" and TCL was installed by the installer.

I am not clear if the package is missing, or if I am misnaming it.

Why does this occur and how can I fix it.

I have tried using someone else's code as an inline proc but this hasn't worked for me yet!


After clarifying the OS Version, I did an 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]>
  • No, sorry, RETTY_NAME="Ubuntu 22.04.1 LTS"
    – Dave Levy
    Jan 2, 2023 at 12:29

1 Answer 1


You don't need to implement the package yourself - cmdline is provided as part of Ubuntu's tcllib package:

$ 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
   * 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,
   * 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

You will need to enable the Universe repository if you haven't already done so.

  • apt-get install tcllib
    – Dave Levy
    Jan 9, 2023 at 22:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .