local a={{name="cd",usage="cd [dir]",desc="Change working directory. Use '-' to return to previous directory.",flags={}},{name="pwd",usage="pwd",desc="Print current working directory.",flags={}},{name="ls",usage="ls [-alh] [dir]",desc="List directory contents. Coloured by type: dirs=blue, symlinks=cyan, executables=green.",flags={{"-a","Show hidden files (starting with .)"},{"-l","Long format: permissions, owner, group, size, mtime, name"},{"-h","Human-readable file sizes (with -l)"},{"--help","Display help and exit"}}},{name="find",usage="find [path] [-name PAT] [-type f|d|l] [-maxdepth N]",desc="Walk the filesystem tree and print matching paths.",flags={{"-name PAT","Match filename against shell glob (* and ?)"},{"-type f|d|l","Filter by file, directory, or symlink"},{"-maxdepth N","Descend at most N directory levels"},{"-mindepth N","Skip entries shallower than N levels"},{"-empty","Match empty files or empty directories"}}},{name="cp",usage="cp [-rRp] SOURCE... DEST",desc="Copy files or directories.",flags={{"-r,-R","Recurse into directories"},{"-p","Preserve permissions"},{"--help","Display help and exit"}}},{name="mv",usage="mv [-f] SOURCE... DEST",desc="Move or rename files and directories.",flags={{"-f","Do not prompt before overwriting (default)"},{"--help","Display help and exit"}}},{name="rm",usage="rm [-rRf] FILE...",desc="Remove files or directories.",flags={{"-r,-R","Recursively remove directories and their contents"},{"-f","Ignore nonexistent files, never prompt"},{"--help","Display help and exit"}}},{name="touch",usage="touch FILE...",desc="Create an empty file, or no-op if it already exists.",flags={}},{name="mkdir",usage="mkdir ",desc="Create a directory.",flags={}},{name="ln",usage="ln -s [-f] TARGET LINK",desc="Create a symbolic link. Multiple targets can be linked into a directory.",flags={{"-s","Create a symbolic link (required; hard links not supported)"},{"-f","Remove existing destination before creating link"},{"--help","Display help and exit"}}},{name="cat",usage="cat [file...]",desc="Print file(s) to stdout. Reads stdin if no file given.",flags={}},{name="head",usage="head [-n N] [file...]",desc="Print the first N lines of each file (default 10).",flags={{"-n N","Number of lines to print"},{"--help","Display help and exit"}}},{name="tail",usage="tail [-n N] [file...]",desc="Print the last N lines of each file (default 10).",flags={{"-n N","Number of lines to print"},{"--help","Display help and exit"}}},{name="wc",usage="wc [-lwc] [file...]",desc="Count lines, words, and bytes in files.",flags={{"-l","Print line count"},{"-w","Print word count"},{"-c","Print byte count"},{"--help","Display help and exit"}}},{name="grep",usage="grep [-ivnlcrR] PATTERN [file...]",desc="Search for lines matching a Lua pattern.",flags={{"-i","Ignore case"},{"-v","Invert: select non-matching lines"},{"-n","Prefix output with line numbers"},{"-l","Print only filenames that contain a match"},{"-c","Print count of matching lines per file"},{"-r,-R","Recurse into directories"},{"--help","Display help and exit"}}},{name="sed",usage="sed 's/PAT/REPL/' [file...]",desc="Stream editor. Applies substitution commands to each line.",flags={}},{name="sort",usage="sort [-rnu] [file...]",desc="Sort lines of text.",flags={{"-r","Reverse the sort order"},{"-n","Numeric sort"},{"-u","Suppress duplicate lines"},{"--help","Display help and exit"}}},{name="uniq",usage="uniq [-cdui] [input [output]]",desc="Filter adjacent duplicate lines.",flags={{"-c","Prefix each line with its repetition count"},{"-d","Print only lines that appear more than once"},{"-u","Print only lines that appear exactly once"},{"-i","Ignore case when comparing"},{"--help","Display help and exit"}}},{name="tee",usage="tee [-a] [file...]",desc="Copy stdin to stdout and to each FILE simultaneously.",flags={{"-a","Append to files instead of overwriting"},{"--help","Display help and exit"}}},{name="basename",usage="basename STRING [SUFFIX]",desc="Strip directory and optional suffix from a path.",flags={}},{name="dirname",usage="dirname STRING...",desc="Strip the last component from a path.",flags={}},{name="readlink",usage="readlink [-fenq] file...",desc="Print the target of a symbolic link.",flags={{"-f","Canonicalize: follow every symlink component"},{"-e","Like -f but all components must exist"},{"-n","Do not output trailing newline"},{"--help","Display help and exit"}}},{name="stat",usage="stat file...",desc="Display file type, size, owner, group, and permissions.",flags={{"--help","Display help and exit"}}},{name="chmod",usage="chmod [-R] MODE file...",desc="Change file permissions. MODE may be octal (755) or symbolic (u+x).",flags={{"-R","Recurse into directories"},{"--help","Display help and exit"}}},{name="chown",usage="chown [-R] USER[:GROUP] file...",desc="Change file owner and/or group.",flags={{"-R","Recurse into directories"},{"--help","Display help and exit"}}},{name="chgrp",usage="chgrp [-R] GROUP file...",desc="Change file group ownership.",flags={{"-R","Recurse into directories"},{"--help","Display help and exit"}}},{name="chattr",usage="chattr [+-=][attrs] file...",desc="Change file attributes.",flags={}},{name="echo",usage="echo [text...]",desc="Print arguments to stdout.",flags={}},{name="whoami",usage="whoami",desc="Print the current username.",flags={}},{name="id",usage="id [username]",desc="Print user identity (uid, gid).",flags={}},{name="ps",usage="ps",desc="List running tasks with pid, user, name, and status.",flags={}},{name="hostname",usage="hostname [NAME]",desc="Print or set the system hostname.",flags={}},{name="uname",usage="uname [-asnrm]",desc="Print system information (OS name, hostname, release, machine).",flags={{"-a","Print all fields"},{"-s","Kernel name"},{"-n","Node hostname"},{"-r","Kernel release"},{"-m","Machine hardware name"},{"--help","Display help and exit"}}},{name="df",usage="df [-h] [path...]",desc="Report filesystem disk space usage.",flags={{"-h","Human-readable sizes (K, M, G)"},{"--help","Display help and exit"}}},{name="stat",usage="stat file...",desc="Display file status: type, size, permissions, owner.",flags={}},{name="env",usage="env [KEY=VAL]... [CMD]",desc="Print the environment, or run a command with modified environment.",flags={}},{name="printenv",usage="printenv [NAME...]",desc="Print environment variable values (all if no names given).",flags={}},{name="sleep",usage="sleep N[smhd]",desc="Pause for N seconds (or minutes/hours/days with m/h/d suffix).",flags={}},{name="true",usage="true",desc="Do nothing, exit successfully (status 0).",flags={}},{name="false",usage="false",desc="Do nothing, exit unsuccessfully (status 1).",flags={}},{name="yes",usage="yes [text]",desc="Repeatedly print 'y' (or given text) until interrupted.",flags={}},{name="mount",usage="mount [-o loop] [SRC DEST | ID MNT]",desc="Mount a loop device or show all current mounts.",flags={{"-o loop","Attach SRC as a loop device and mount at DEST in one step"},{"--help","Display help and exit"}}},{name="umount",usage="umount [--no-detach] MOUNTPOINT | -l LOOPID",desc="Unmount a filesystem and auto-detach its loop device.",flags={{"--no-detach","Unmount but keep loop device attached"},{"-l LOOPID","Force-detach a loop device without unmounting"},{"--help","Display help and exit"}}},{name="losetup",usage="losetup [-dil] [path]",desc="Attach a directory or .hfs image as a loop device.",flags={{"-d ID","Detach loop device"},{"-i path","Force image mode (even without .hfs extension)"},{"-l","List all attached loop devices"},{"--help","Display help and exit"}}},{name="loimgcreate",usage="loimgcreate [-x] SRC DEST",desc="Pack a directory into a portable HFS image, or extract one.",flags={{"-x","Extract image to destination directory"},{"--help","Display help and exit"}}},{name="useradd",usage="useradd [-p pw] [-g gid] [-d home] [-s shell] [-M] ",desc="Create a new user account.",flags={{"-p pw","Set password"},{"-g gid","Set primary group id"},{"-d home","Set home directory (default /home/username)"},{"-s shell","Set login shell (default /bin/hysh)"},{"-M","Do not create home directory"}}},{name="userdel",usage="userdel [-r] ",desc="Delete a user account.",flags={{"-r","Also remove the user's home directory"}}},{name="usermod",usage="usermod [-l name] [-p pw] [-g gid] [-d home] [-s shell] [-LU] ",desc="Modify an existing user account.",flags={{"-l name","Rename the user"},{"-p pw","Set new password"},{"-g gid","Change primary group id"},{"-d home","Change home directory"},{"-s shell","Change login shell"},{"-L","Lock the account"},{"-U","Unlock the account"}}},{name="passwd",usage="passwd [username]",desc="Change a user password.",flags={}},{name="lsusers",usage="lsusers",desc="List all user accounts with uid, gid, home, and shell.",flags={}},{name="su",usage="su [username]",desc="Switch user. Defaults to root. Root can switch without a password.",flags={}},{name="sudo",usage="sudo [-u user] CMD [args...]",desc="Run a command as another user (default root).",flags={{"-u user","Run as the specified user (name or uid)"}}},{name="exit",usage="exit [N]",desc="Exit the shell with optional status code N.",flags={}},{name="clear",usage="clear",desc="Clear the terminal screen.",flags={}},{name="help",usage="help [command]",desc="Display this command reference. Pass a command name to filter.",flags={}},{name="lua",usage="lua",desc="Interactive Lua REPL prompt.",flags={}},{name="micro",usage="micro [file]",desc="Full-screen terminal text editor.",flags={}},{name="hfetch",usage="hfetch",desc="Display system information in a neofetch-style layout.",flags={}},{name="sysdump",usage="sysdump",desc="List all registered kernel syscalls.",flags={}},{name="chroot",usage="chroot DIR [CMD]",desc="Run a command with a different root directory.",flags={}}}do local b={}local c={}for d,e in ipairs(a)do if not b[e.name]then b[e.name]=true;table.insert(c,e)end end;a=c end;local f=7;local g=5;local h=1;local i=13;local j=3;local k=12;local l={}local function m(n,o)l[#l+1]={n,o or 1}end;m("HyperionOS Command Reference",f)m(string.rep("=",50),k)m("",1)local p={...}local q=p[1]local function r(e)m(e.name,g)m(" Usage: "..e.usage,h)m(" "..e.desc,i)if#e.flags>0 then for d,s in ipairs(e.flags)do m(" "..s[1],j)m(" "..s[2],i)end end;m("",1)end;if q then local t=false;for d,e in ipairs(a)do if e.name==q then r(e)t=true;break end end;if not t then m("help: unknown command '"..q.."'",2)m("Run 'help' with no arguments for the full list.",i)end else m("Run 'help ' for details on a specific command.",i)m("",1)for d,e in ipairs(a)do r(e)end end;local u=syscall.devctl(1,"size")local v=tonumber(u:match("^(%d+)"))or 51;local w=tonumber(u:match(";(%d+)"))or 19;local x=w-2;local y=0;local z=#l;local A=true;local function B()syscall.devctl(1,"clear")syscall.devctl(1,"spos",1,1)for C=1,x do local D=y+C;if D<=z then local n,o=l[D][1],l[D][2]syscall.devctl(1,"sfgc",o)if#n>v then n=n:sub(1,v)end;syscall.write(1,n.."\n")else syscall.write(1,"\n")end end;syscall.devctl(1,"sfgc",0x000000)syscall.devctl(1,"sbgc",0xDBDBDB)local E=math.floor(math.min(100,(y+x)/z*100))local F=string.format(" help -- line %d/%d (%d%%) [up/down: scroll q: quit] ",y+1,z,E)if#F>v then F=F:sub(1,v)end;syscall.devctl(1,"spos",1,w)syscall.write(1,F..string.rep(" ",v-#F))syscall.devctl(1,"sfgc",0xFFFFFF)syscall.devctl(1,"sbgc",0x000000)A=false end;if z<=x then syscall.devctl(1,"clear")syscall.devctl(1,"spos",1,1)for d,G in ipairs(l)do syscall.devctl(1,"sfgc",G[2])syscall.write(1,G[1].."\n")end;syscall.devctl(1,"sfgc",0xFFFFFF)return end;B()while true do local H=syscall.read(0)if not H or H==""then elseif H=="q"or H=="Q"then break elseif H=="\17"then if y>0 then y=y-1;A=true end elseif H=="\18"then if y+x