Skip to content

Commit 2a35070

Browse files
committed
Improve cellc CLI diagnostics
1 parent 32a967c commit 2a35070

7 files changed

Lines changed: 357 additions & 77 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## 0.20.0-nightly - 2026-06-19
44

5+
- Bring `cellc` CLI discovery and direct-source diagnostics closer to Rust's
6+
developer experience: top-level help now shows package commands plus direct
7+
compile mode, `cellc --list` enumerates commands, unknown bare commands get
8+
nearest-command suggestions, and direct parse/lex/compile errors print
9+
`file:line:column` source snippets.
510
- Fix numeric-width soundness by requiring exact non-literal numeric type
611
equality while preserving declared integer literal widths through type
712
checking and IR lowering.

‎Cargo.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ repository = "https://github.com/CellScript-Labs/CellScript"
2727
exclude = [
2828
".audit-report*.md",
2929
".cap/",
30+
".codex/",
3031
".gitignore",
32+
".gitmodules",
3133
".playwright-mcp/",
3234
".rustfmt.toml",
3335
".github/",
36+
"AGENTS.md",
3437
"BRANCHES.md",
3538
"README_REVIEW.md",
3639
"cellscript-*.png",
@@ -39,6 +42,7 @@ exclude = [
3942
"editors/",
4043
"proposals/",
4144
"scripts/__pycache__/",
45+
"services/",
4246
"src/bin/",
4347
"tools/",
4448
"website/",

‎docs/wiki/Tutorial-01-Getting-Started.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,21 @@ Or call the built binary directly:
4848

4949
Both forms are useful. `cargo run` is convenient while developing the compiler.
5050
The direct binary is closer to how users call `cellc` after installation.
51-
The top-level help shows the legacy direct single-file compiler flags. Package
52-
commands have their own help pages:
51+
The top-level help shows both direct source mode and the package command surface.
52+
Package commands have their own help pages:
5353

5454
```bash
5555
./target/debug/cellc build --help
5656
./target/debug/cellc check --help
5757
./target/debug/cellc init --help
5858
```
5959

60+
To list every package command without the direct source options, use:
61+
62+
```bash
63+
./target/debug/cellc --list
64+
```
65+
6066
## Compile One Source File
6167

6268
Start with `examples/token.cell`. It is small, but it already shows the main

‎scripts/cellscript_gate.sh‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ run() {
2727
"$@"
2828
}
2929

30+
cargo_fmt_workspace() {
31+
run cargo fmt \
32+
--manifest-path "$ROOT_DIR/Cargo.toml" \
33+
--package cellscript \
34+
--package cellscript-ckb-adapter \
35+
--package cellscript-wasm \
36+
--package cellscript-ckb-sdk-builder-example \
37+
"$@"
38+
}
39+
3040
python_syntax_check() {
3141
python3 - "$@" <<'PY'
3242
import sys
@@ -574,7 +584,7 @@ run_dev_gate() {
574584
require_cmd python3
575585
require_cmd rg
576586

577-
run cargo fmt --all
587+
cargo_fmt_workspace
578588
run cargo check --locked -p cellscript --all-targets
579589
run ./scripts/cellscript_strict_backend_audit.sh quick
580590
run ./scripts/cellscript_syntax_combo_audit.sh quick
@@ -593,7 +603,7 @@ run_ci_gate() {
593603
require_cmd npm
594604

595605
printf '{"status":"not-generated","reason":"test suite did not reach backend shape report generation"}\n' >"$CELLSCRIPT_BACKEND_SHAPE_REPORT"
596-
run cargo fmt --all --check
606+
cargo_fmt_workspace --check
597607
run cargo test --locked -p cellscript -- --test-threads=1
598608
run cargo clippy --locked -p cellscript --all-targets -- -D warnings
599609
run ./scripts/cellscript_strict_backend_audit.sh ci
@@ -615,7 +625,7 @@ run_backend_gate() {
615625
require_cmd python3
616626
require_cmd rg
617627

618-
run cargo fmt --all --check
628+
cargo_fmt_workspace --check
619629
run cargo check --locked -p cellscript --all-targets
620630
run cargo test --locked -p cellscript
621631
run cargo clippy --locked -p cellscript --all-targets -- -D warnings

‎src/cli/commands.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10657,9 +10657,13 @@ pub struct CliParser;
1065710657

1065810658
impl CliParser {
1065910659
pub fn parse() -> Command {
10660+
Self::parse_matches(Self::command().get_matches())
10661+
}
10662+
10663+
pub fn command() -> clap::Command {
1066010664
use clap::{Arg, ArgAction, Command as ClapCommand};
1066110665

10662-
let matches = ClapCommand::new("cellc")
10666+
ClapCommand::new("cellc")
1066310667
.version(crate::VERSION)
1066410668
.about("CellScript compiler for CKB blockchain")
1066510669
.subcommand_required(true)
@@ -11584,8 +11588,9 @@ impl CliParser {
1158411588
.arg(Arg::new("name").long("name").required(true).value_name("NAME").help("Package name"))
1158511589
.arg(Arg::new("source").long("source").required(true).value_name("URL").help("Source repository URL")),
1158611590
)
11587-
.get_matches();
11591+
}
1158811592

11593+
fn parse_matches(matches: clap::ArgMatches) -> Command {
1158911594
match matches.subcommand() {
1159011595
Some(("build", m)) => Command::Build(BuildArgs {
1159111596
release: m.get_flag("release"),

0 commit comments

Comments
 (0)