.\" Made by website/plain/build.mjs from website/words/sg-help.md; change that file. .TH SG-HELP 1 2026-11-28 "SG" "SG commands" .SH NAME sg help \- prints the page of a word, a sign or a command of SG in the terminal, from sg itself, with no network .SH SYNOPSIS .TP \fBsg help name\fR the page of a word (sg help read), or the line of any other name of the index .TP \fBsg help\fR the commands and the words that have a page, each with its line .TP \fBsg help index\fR every name of SG, by kind, with what it is in one line .TP \fBsg help build, sg help sg\-build, sg help "sg build"\fR the page of a command .TP \fBsg help '??'\fR a sign, by its marks alone .TP \fBsg build \-\-help, sg \-h\fR the page of a command, asked of the command itself .TP \fBsg help \-\-help\fR prints this page .SH DESCRIPTION \fBsg help\fR prints a page of the reference to the output. The pages are carried in \fBsg\fR itself, so it needs no network and nothing installed beside it, and it prints the same on every system. A page is the text \fBman\fR shows for the manual page of the same name (\fBsg\-read(7)\fR, \fBsg\-build(1)\fR), without man's top and foot lines, and with the pages under SEE ALSO named as \fBsg help\fR finds them; the site has the same page. It is plain text, with no colour and no pager: \fBsg help read | less\fR pages it, and \fBgrep\fR searches it. .PP The name is looked for as it is written, then in any case, then as a command (\fBbuild\fR is \fBsg build\fR), then as the name of a page's file (\fBsg\-build\fR, \fBnull\-coalescing\fR), then, for a sign, by its marks alone: \fB??\fR is \fBx ?? y\fR, \fB[^]\fR is \fBxs[^1]\fR\&. A name of the index with no page yet, such as a type of the library, gives its line and the address of the site that says more. The keyword \fBtest\fR is found before the command, so \fBsg help test\fR is the keyword and \fBsg help sg\-test\fR the command. .PP A command prints its own page too: \fB\-\-help\fR or \fB\-h\fR among the words of \fBsg build\fR, \fBsg test\fR, \fBsg emit\-c\fR, \fBsg lsp\fR, \fBsg help\fR or \fBsg add\fR (before a \fB\-\-\fR) prints what \fBsg help sg\-build\fR prints, and \fBsg \-\-help\fR prints the page of \fBsg\fR\&. After a program the words are the program's, so \fBsg main.sg \-\-help\fR gives \fB\-\-help\fR to \fBmain\fR\&. .PP It ends with code 0 when it printed a page or a line. A name it does not know is an error on the standard error, which names the names that start like it, and ends with code 2; so do an empty name and more than one name. .PP The pages are as new as the \fBsg\fR that carries them: they are built from the same files as the site, when \fBsg\fR is built. .SH EXAMPLES .SS "The page of a word" .RS 4 .nf $ sg help break | head -2 NAME break - leaves the loop it is in, or the loop it names, at once $ sg help break | grep '^[A-Z]' NAME SYNOPSIS DESCRIPTION EXAMPLES WHAT THE COMPILER REFUSES SEE ALSO .fi .RE .PP A page has the parts of a manual page: what the word is, its forms, what it means, the examples, and what the compiler refuses. The text is wrapped at 78 columns; the lines of programs and of what they print are kept whole. .SS "What there is to read" .RS 4 .nf $ sg help | head -4 SG HELP sg help the page of a word, or the line of any other name sg help index every name of SG, with what it is in one line sg build --help the page of a command; so does sg help sg-build $ sg help index | grep '^[A-Z]' KEYWORDS PRIMITIVE TYPES VALUES WITH A NAME SIGNS TYPES OF THE LIBRARY MODULES OF THE LIBRARY COMMANDS .fi .RE .PP \fBsg help\fR goes on with the commands and the words that have a page; \fBsg help index\fR lists every name under these headings, each with its line. .SS "One page, several names" .RS 4 .nf $ sg help read > read.txt $ sg help READ | cmp - read.txt && echo same same $ sg help build > build.txt $ sg help sg-build | cmp - build.txt && sg help "sg build" | cmp - build.txt && echo same same $ sg build --help | cmp - build.txt && echo same same $ sg help '??' | head -2 NAME x ?? y - the value of x, or y when x is null or an error $ sg help test | head -3 NAME test - a block of checks written next to the code, which only sg test compiles and runs .fi .RE .PP \fBREAD\fR is found in any case, \fBbuild\fR as the command \fBsg build\fR, and \fB??\fR as the sign \fBx ?? y\fR\&. \fBtest\fR is the keyword; the command's page is \fBsg help sg\-test\fR\&. .SS "A name with no page yet" .RS 4 .nf $ sg help Duration NAME Duration - a type of the library, in Time A library type of SG. sg help has no page for it yet; the site says more: https://sg-lang.org/library/time#duration .fi .RE .PP The types and the modules of the library are names of the index; their methods are on the pages of the library, on the site. .SS "A name it does not know" .RS 4 .nf $ sg help whil; echo "exit code $?" error: SG has no name `whil` that `sg help` knows; names that start like it: `while` exit code 2 $ sg help zebra; echo "exit code $?" error: SG has no name `zebra` that `sg help` knows; `sg help index` lists every name exit code 2 $ sg help read write 2>/dev/null; echo "exit code $?" exit code 2 $ sg help ''; echo "exit code $?" error: `sg help` takes a name, and this one is empty; `sg help` alone lists the commands and the words with a page exit code 2 .fi .RE .PP Two names are not a usage: \fBsg help\fR writes how \fBsg\fR is used, to the standard error. An empty name, as a variable of the shell that holds nothing gives, is told as one. .SH "MISTAKES IT TELLS" .SS "A sign the shell reads first" .RS 4 .nf $ touch zz $ sg help ?? error: SG has no name `zz` that `sg help` knows; `sg help index` lists every name $ sg help '??' | head -2 NAME x ?? y - the value of x, or y when x is null or an error .fi .RE .PP \fB?\fR, \fB*\fR and \fB[\fR are patterns of file names to the shell, so \fB??\fR became the file \fBzz\fR before \fBsg\fR saw it. In quotes, the shell gives the sign as it is. .SH "SEE ALSO" .BR sg (1), .BR sg-build (1), .BR sg-test (1), .BR sg-test (7), .BR sg-null-coalescing (7) .PP https://sg\-lang.org/reference/sg-help.html