beetlebug▾
/

ztcl::code show

Gives lines of a file with their numbers.

ztcl::code show FILE ?SPEC ...? ?-n MAX?

Description

A SPEC is A-B, A+N (N lines from A), A (40 lines from A), -N (the last N lines), A- (to the end), or the name of a definition, as in def. With no SPEC, the full file shows. At most MAX lines (300) of each SPEC show, and a last line gives the command for the rest. A name that is not in the outline gives the error NONAME with the names that have the text of NAME.

Returns

The lines as N<tab>TEXT.

Examples

Each example of this page runs after package require ztcl::code # A folder with three files, outside a git tree. set dir /tmp/ztcl-ref-code-[pid] file delete -force $dir file mkdir $dir cd $dir proc put {path text} { set ch [open $path w] puts -nonewline $ch $text close $ch } put a.zig "const std = @import(\"std\");\n\npub const Point = struct {\n x: i32,\n\n pub fn len(p: Point) i32 {\n return p.x;\n }\n};\n" put b.txt "one\ntwo\ntwo\n" put c.md "# Title\n\n## Part\n\ntext\n" # The tests use no model. set ::ztcl::code::backend {http ""} set ::ztcl::code::llm_url http://127.0.0.1:9/v1/chat/completions .

% ztcl::code show a.zig len
6	    pub fn len(p: Point) i32 {
7	        return p.x;
8	    }

% ztcl::code show b.txt -1
3	two

Errors

% ztcl::code show a.zig Pt
no entry Pt in the outline of a.zig
-errorcode ZTCL CODE NONAME

% ztcl::code show nope.txt
no file nope.txt
-errorcode ZTCL CODE NOFILE

Facts

Capability
file. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.2