Skip to content

Commit 44ba3c4

Browse files
committed
doc: update cli flags
1 parent 386c41c commit 44ba3c4

File tree

1 file changed

+113
-25
lines changed

1 file changed

+113
-25
lines changed

book/cli.md

Lines changed: 113 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,38 @@ library, the [compiler](https://github.com/cakevm/huff-neo)'s CLI offers some ad
77
## Options
88

99
```plaintext
10-
hnc 0.3.0
1110
Huff Language Compiler built in Pure Rust.
1211
13-
USAGE:
14-
hnc [OPTIONS] [PATH] [SUBCOMMAND]
15-
16-
ARGS:
17-
<PATH> The contract(s) to compile
18-
19-
OPTIONS:
20-
-a, --artifacts Whether to generate artifacts or not
21-
-b, --bytecode Generate and log bytecode
22-
-c, --constants <CONSTANTS>... Override / set constants for the compilation environment
23-
-d, --output-directory <OUTPUTDIR> The output directory [default: ./artifacts]
24-
-g, --interface [<INTERFACE>...] Generate solidity interface for a Huff artifact
25-
-h, --help Print help information
26-
-i, --inputs <INPUTS>... The input constructor arguments
27-
-n, --interactive Interactively input the constructor args
28-
-o, --output <OUTPUT> The output file path
29-
-r, --bin-runtime Generate and log runtime bytecode
30-
-s, --source-path <SOURCE> The contracts source path [default: ./contracts]
31-
-v, --verbose Verbose output
32-
-V, --version Print version information
33-
34-
SUBCOMMANDS:
35-
help Print this message or the help of the given subcommand(s)
36-
test Test subcommand
12+
Usage: hnc [OPTIONS] [PATH] [COMMAND]
13+
14+
Commands:
15+
test Test subcommand
16+
help Print this message or the help of the given subcommand(s)
17+
18+
Arguments:
19+
[PATH] The contract(s) to compile
20+
21+
Options:
22+
-s, --source-path <SOURCE> The contracts source path [default: ./contracts]
23+
-o, --output <OUTPUT> The output file path
24+
-d, --output-directory <OUTPUTDIR> The output directory [default: ./artifacts]
25+
-i, --inputs <INPUTS>... The input constructor arguments
26+
-n, --interactive Interactively input the constructor args
27+
-a, --artifacts Whether to generate artifacts or not
28+
--relax-jumps Apply branch relaxation to minimize deployment gas
29+
-g, --interface [<INTERFACE>...] Generate solidity interface for a Huff artifact
30+
-b, --bytecode Generate and log bytecode
31+
-r, --bin-runtime Generate and log runtime bytecode
32+
-p, --print Prints out to the terminal
33+
-v, --verbose Verbose output
34+
-l, --label-indices Prints out the jump label PC indices for the specified contract
35+
-c, --constants <CONSTANTS>... Override / set constants for the compilation environment
36+
-m, --alt-main <ALTERNATIVE_MAIN> Compile a specific macro
37+
-t, --alt-constructor <ALT_CONSTRUCTOR> Compile a specific constructor macro
38+
-e, --evm-version <EVM_VERSION> Set the EVM version [default: osaka]
39+
--flattened-source Output the flattened source code with all dependencies resolved
40+
-V, --version Print version
41+
-h, --help Print help
3742
```
3843

3944
### `-a` Artifacts
@@ -87,6 +92,33 @@ Example:
8792
hnc ./src/ERC20.huff -d ./my_artifacts
8893
```
8994

95+
### `-e` EVM Version
96+
97+
Arguments: `<EVM_VERSION>`, Default: `osaka`
98+
99+
Passing the `-e` flag allows you to set the target EVM version for compilation.
100+
This determines which opcodes are available. Supported versions:
101+
- `paris` - PREVRANDAO
102+
- `shanghai` - PUSH0
103+
- `cancun` - TLOAD, TSTORE, MCOPY, BLOBHASH, BLOBBASEFEE
104+
- `prague` - No new opcodes
105+
- `osaka` - CLZ (default)
106+
107+
Example:
108+
```shell
109+
hnc ./src/ERC20.huff -e cancun
110+
```
111+
112+
### `--flattened-source`
113+
114+
Passing the `--flattened-source` flag outputs the flattened source code with all
115+
dependencies and includes resolved into a single output.
116+
117+
Example:
118+
```shell
119+
hnc ./src/ERC20.huff --flattened-source
120+
```
121+
90122
### `-g` Interface
91123

92124
Passing the `-g` flag will generate a Solidity interface for the Huff contract
@@ -115,6 +147,29 @@ Example (assuming `ERC20.huff`'s constructor accepts a String and a uint):
115147
hnc ./src/ERC20.huff -i "TestToken", 18
116148
```
117149

150+
### `-l` Label Indices
151+
152+
Passing the `-l` flag prints out the jump label PC (program counter) indices
153+
for the specified contract. This is useful for debugging and understanding
154+
where labels resolve to in the final bytecode.
155+
156+
Example:
157+
```shell
158+
hnc ./src/ERC20.huff -l
159+
```
160+
161+
### `-m` Alternative Main
162+
163+
Arguments: `<ALTERNATIVE_MAIN>`
164+
165+
Passing the `-m` flag allows you to compile a specific macro as the main
166+
entry point instead of the default `MAIN` macro.
167+
168+
Example:
169+
```shell
170+
hnc ./src/Contract.huff -m MY_CUSTOM_MAIN
171+
```
172+
118173
### `-n` Interactive Inputs
119174

120175
Passing the `-n` flag allows you to input constructor arguments
@@ -137,6 +192,27 @@ Example:
137192
hnc ./src/ERC20.huff -o ./artifact.json
138193
```
139194

195+
### `-p` Print
196+
197+
Passing the `-p` flag prints the compilation output to the terminal.
198+
199+
Example:
200+
```shell
201+
hnc ./src/ERC20.huff -p
202+
```
203+
204+
### `--relax-jumps`
205+
206+
Passing the `--relax-jumps` flag applies branch relaxation to minimize deployment
207+
gas costs. When enabled, all pushes for jumps will be minimized to PUSH1 where
208+
possible. This can reduce deployment gas costs but has no effect on runtime gas
209+
costs. Only applies to label references used in JUMPI and JUMP opcodes.
210+
211+
Example:
212+
```shell
213+
hnc ./src/ERC20.huff --relax-jumps -b
214+
```
215+
140216
### `-s` Source Path
141217

142218
Arguments: `<CONTRACTS_FOLDER>`, Default: `./contracts`
@@ -149,6 +225,18 @@ Example:
149225
hnc -s ./src/
150226
```
151227

228+
### `-t` Alternative Constructor
229+
230+
Arguments: `<ALTERNATIVE_CONSTRUCTOR>`
231+
232+
Passing the `-t` flag allows you to compile a specific macro as the constructor
233+
entry point instead of the default `CONSTRUCTOR` macro.
234+
235+
Example:
236+
```shell
237+
hnc ./src/Contract.huff -t MY_CUSTOM_CONSTRUCTOR
238+
```
239+
152240
### `-r` Runtime Bytecode
153241

154242
Passing the `-r` flag will tell the compiler to print the runtime bytecode

0 commit comments

Comments
 (0)