improved help

This commit is contained in:
2026-02-18 12:00:46 -06:00
parent d8422ae69b
commit 28f5a108d8
12 changed files with 125 additions and 47 deletions

View File

@@ -1,3 +1,5 @@
// cell bench - Run benchmarks with statistical analysis
var shop = use('internal/shop')
var pkg = use('package')
var fd = use('fd')

View File

@@ -1,3 +1,5 @@
// cell dump_ir - Dump intermediate representation for a source file
var shop = use('internal/shop')
var json = use('json')

View File

@@ -1,3 +1,5 @@
// cell fold - Run constant folding on a source file
var json = use("json")
var shop = use("internal/shop")
var filename = args[0]

150
help.ce
View File

@@ -1,11 +1,28 @@
// cell help - Display help information for cell commands
var fd = use('fd')
var package = use('package')
var shop = use('internal/shop')
var command = length(args) > 0 ? args[0] : null
var core_dir = shop.get_package_dir('core')
var man_file = null
var stat = null
var content = null
var lines = null
var line = null
var block = null
var ce_path = null
var i = 0
var programs = null
var top_level = []
var descriptions = []
var max_len = 0
var first_line = null
var desc = null
var sep = null
var padding = null
var j = 0
// Display specific command help
if (command) {
@@ -15,56 +32,95 @@ if (command) {
content = text(fd.slurp(man_file))
log.console(content)
} else {
log.error("No help available for command: " + command)
log.console("Run 'cell help' to see available commands.")
ce_path = core_dir + '/' + command + '.ce'
stat = fd.stat(ce_path)
if (stat && stat.isFile) {
content = text(fd.slurp(ce_path))
lines = array(content, '\n')
block = ""
for (i = 0; i < length(lines); i++) {
line = lines[i]
if (starts_with(line, '// ')) {
block = block + text(line, 3, length(line)) + '\n'
} else if (line == '//') {
block = block + '\n'
} else if (starts_with(line, '//')) {
block = block + text(line, 2, length(line)) + '\n'
} else {
i = length(lines)
}
}
if (length(block) > 0) {
log.console(trim(block))
} else {
log.error("No help available for command: " + command)
log.console("Run 'cell help' to see available commands.")
}
} else {
log.error("No help available for command: " + command)
log.console("Run 'cell help' to see available commands.")
}
}
} else {
// Display general help — dynamic listing
programs = sort(package.list_programs('core'))
for (i = 0; i < length(programs); i++) {
if (search(programs[i], '/') == null) {
top_level[] = programs[i]
}
$stop()
}
// Display general help
man_file = 'scripts/man/cell.man'
stat = fd.stat(man_file)
if (stat && stat.isFile) {
content = text(fd.slurp(man_file))
log.console(content)
} else {
// Fallback if man file doesn't exist
log.console("cell - The Cell package manager")
log.console("")
log.console("Usage: cell <command> [arguments]")
log.console("")
log.console("Package Management:")
log.console(" install <locator> Install a package and its dependencies")
log.console(" update [locator] Update packages from remote sources")
log.console(" remove <locator> Remove a package from the shop")
log.console(" add <locator> Add a dependency to current package")
log.console("")
log.console("Building:")
log.console(" build [locator] Build dynamic libraries for packages")
log.console(" clean [scope] Remove build artifacts")
log.console("")
log.console("Linking (Local Development):")
log.console(" link <origin> <target> Link a package to a local path")
log.console(" unlink <origin> Remove a package link")
log.console(" clone <origin> <path> Clone and link a package locally")
log.console("")
log.console("Information:")
log.console(" list [scope] List packages and dependencies")
log.console(" ls [locator] List modules and actors in a package")
log.console(" why <locator> Show reverse dependencies")
log.console(" search <query> Search for packages, modules, or actors")
log.console("")
log.console("Diagnostics:")
log.console(" resolve [locator] Print fully resolved dependency closure")
log.console(" graph [locator] Emit dependency graph (tree, dot, json)")
log.console(" verify [scope] Verify integrity and consistency")
log.console(" audit [locator] Test-compile all scripts in package(s)")
log.console("")
log.console("Other:")
log.console(" help [command] Show help for a command")
log.console(" version Show cell version")
log.console("")
log.console("Run 'cell <command> --help' for more information on a command.")
for (i = 0; i < length(top_level); i++) {
ce_path = core_dir + '/' + top_level[i] + '.ce'
desc = ""
stat = fd.stat(ce_path)
if (stat && stat.isFile) {
content = text(fd.slurp(ce_path))
lines = array(content, '\n')
first_line = length(lines) > 0 ? lines[0] : ""
if (starts_with(first_line, '//')) {
if (starts_with(first_line, '// ')) {
first_line = text(first_line, 3, length(first_line))
} else {
first_line = text(first_line, 2, length(first_line))
}
sep = search(first_line, ' - ')
if (sep != null) {
desc = text(first_line, sep + 3, length(first_line))
} else {
sep = search(first_line, ' — ')
if (sep != null) {
desc = text(first_line, sep + 3, length(first_line))
} else {
desc = first_line
}
}
}
}
descriptions[] = desc
if (length(top_level[i]) > max_len) {
max_len = length(top_level[i])
}
}
log.console("cell - the cell package manager")
log.console("")
log.console("usage: cell <command> [arguments]")
log.console("")
log.console("available commands:")
for (i = 0; i < length(top_level); i++) {
padding = ""
for (j = 0; j < max_len - length(top_level[i]); j++) {
padding = padding + " "
}
if (length(descriptions[i]) > 0) {
log.console(" " + top_level[i] + padding + " " + descriptions[i])
} else {
log.console(" " + top_level[i])
}
}
log.console("")
log.console("Run 'cell help <command>' for more information.")
}
$stop()

View File

@@ -1,3 +1,5 @@
// cell parse - Parse a source file and output AST as JSON
var json = use("json")
var shop = use("internal/shop")
var filename = args[0]

2
qbe.ce
View File

@@ -1,3 +1,5 @@
// cell qbe - Compile a source file to QBE intermediate language
var fd = use("fd")
var json = use("json")
var tokenize = use("tokenize")

View File

@@ -1,3 +1,5 @@
// cell qopconv - Convert QOP archive formats
var fd = use('fd')
var qop = use('qop')

View File

@@ -1,3 +1,5 @@
// cell test - Run tests for packages
var shop = use('internal/shop')
var pkg = use('package')
var fd = use('fd')

View File

@@ -1,3 +1,5 @@
// cell tokenize - Tokenize a source file and output token stream
var json = use("json")
var shop = use("internal/shop")
var filename = args[0]

View File

@@ -1,3 +1,5 @@
// cell upgrade - Upgrade the cell installation
var shop = use('internal/shop')
var fd = use('fd')

View File

@@ -1,2 +1,4 @@
// cell version - Show cell version
log.console("0.1.0")
$stop()

2
why.ce
View File

@@ -1,3 +1,5 @@
// cell why - Show reverse dependencies for a package
var shop = use('internal/shop')
var pkg = use('package')