docs/content/references/cli/move.mdx
The Sui CLI move command provides several commands for working with Move source code. A typical usage of sui move is to compile and test the Move code, or to generate a new Move project by using sui move new project_name, which creates the needed directories and the Move.toml file.
$ sui move --help
The following examples demonstrate some of the most often used commands.
To create a new Move project that automatically adds the necessary dependencies in a Move.toml file, run sui move new [<PROJECT-NAME>].
$ sui move new smart_contract_test
$ ls -l smart_contract_test
Move.toml
Sources
Display the contents of Move.toml file.
$ cat smart_contract_test/Move.toml
[package]
name = "smart_contract_test"
version = "0.0.1"
[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }
[addresses]
smart_contract_test = "0x0"
Use sui move build at the root of your Move project to build the package.
$ sui move build
UPDATING GIT DEPENDENCY https://github.com/MystenLabs/sui.git
INCLUDING DEPENDENCY Sui
INCLUDING DEPENDENCY MoveStdlib
BUILDING smart_contract_test
Use sui move test to run the tests in a Move package.
$ sui move test
UPDATING GIT DEPENDENCY https://github.com/MystenLabs/sui.git
INCLUDING DEPENDENCY Sui
INCLUDING DEPENDENCY MoveStdlib
BUILDING smart_contract_test
Running Move unit tests
Test result: OK. Total tests: 0; passed: 0; failed: 0
:::caution
This command currently only works on debug builds of the CLI. Please build the CLI from source to use it.
:::
This example uses first_package Move package.
To get a summary of the test coverage, you must first run the sui move test --coverage command, and then the sui move coverage summary --test to get a summary of the test coverage in the example project.
$ sui move test --coverage
INCLUDING DEPENDENCY Sui
INCLUDING DEPENDENCY MoveStdlib
BUILDING first_package
Running Move unit tests
[ PASS ] 0x0::example::test_module_init
[ PASS ] 0x0::example::test_sword_transactions
Test result: OK. Total tests: 2; passed: 2; failed: 0
$ sui move coverage summary --test
+-------------------------+
| Move Coverage Summary |
+-------------------------+
Module 0000000000000000000000000000000000000000000000000000000000000000::example
>>> % Module coverage: 92.81
+-------------------------+
| % Move Coverage: 92.81 |
+-------------------------+
Each command has its own help section. For example:
$ sui move build --help