Sui Move CLI
Sui CLI move 명령은 Move 소스 코드 작업을 위한 여러 명령을 제공한다. sui move 의 일반적인 사용법은 Move 코드를 컴파일하고 테스트하거나, sui move new project_name 사용하여 새 Move 프로젝트를 생성하는 것이다. 이 명령은 필요한 디렉터리와 Move.toml 파일을 생성한다.
Commands
터미널이나 콘솔에 sui move --help 입력하면 사용 가능한 명령에 대한 다음 정보가 표시된다.
Usage: sui move [OPTIONS] <COMMAND>
Commands:
build
coverage Inspect test coverage for this package. A previous test run with the `--coverage` flag must have previously been run
disassemble
manage-package Record addresses (Object IDs) for where this package is published on chain (this command sets variables in Move.lock)
migrate Migrate to Move 2024 for the package at `path`. If no path is provided defaults to current directory
new Create a new Move package with name `name` at `path`. If `path` is not provided the package will be created in the directory `name`
test Run Move unit tests in this package
help Print this message or the help of the given subcommand(s)
Options:
-p, --path <PACKAGE_PATH> Path to a package which the command should be run with respect to
-d, --dev Compile in 'dev' mode. The 'dev-addresses' and 'dev-dependencies' fields will be used if this flag is set. This flag is useful for
development of packages that expose named addresses that are not set to a specific value
--test Compile in 'test' mode. The 'dev-addresses' and 'dev-dependencies' fields will be used along with any code in the 'tests' directory
--doc Generate documentation for packages
--abi Generate ABIs for packages
--install-dir <INSTALL_DIR> Installation directory for compiled artifacts. Defaults to current directory
--force Force recompilation of all packages
--fetch-deps-only Only fetch dependency repos to MOVE_HOME
--skip-fetch-latest-git-deps Skip fetching latest git dependencies
--default-move-flavor <DEFAULT_FLAVOR> Default flavor for move compilation, if not specified in the package's config
--default-move-edition <DEFAULT_EDITION> Default edition for move compilation, if not specified in the package's config
--dependencies-are-root If set, dependency packages are treated as root packages. Notably, this will remove warning suppression in dependency packages
-h, --help Print help
-V, --version Print version
Examples
다음 예제에서는 가장 자주 사용되는 명령 중 일부를 보여준다.
Create a new Move project
Move.toml 파일에 필요한 종속성을 자동으로 추가하는 새로운 Move 프로젝트를 만들려면 sui move new [<PROJECT-NAME>] 를 실행한다.
$ sui move new smart_contract_test
$ ls -l smart_contract_test
Move.toml
Sources
Move.toml 파일의 내용을 표시한다.
$ 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"
Build a Move project
Move 프로젝트의 루트에서 sui move build 사용하여 패키지를 빌드한다.
$ sui move build
UPDATING GIT DEPENDENCY https://github.com/MystenLabs/sui.git
INCLUDING DEPENDENCY Sui
INCLUDING DEPENDENCY MoveStdlib
BUILDING smart_contract_test
Run tests in a Move project
sui move test 사용하여 Move 패키지에서 테스트를 실행한다.
$ 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
Get test coverage for a module
이 명령은 현재 CLI 디버그 빌드에서만 작동한다. 사용하기 위해서는 소스에서 CLI를 빌드하길 바란다.
이 예제에서는 first_package Move 패키지를 사용한다.
테스트 커버리지 요약을 얻으려면 먼저 sui move test --coverage 명령을 실행한 다음, sui move coverage summary --test 실행하여 예제 프로젝트의 테스트 커버리지 요약을 받아야 한다.
$ 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 |
+-------------------------+
Help
각 명령에는 자체 도움말 섹션이 있다. 예를 들어 sui move build --help 입력하면 다음과 같은 프롬프트가 표시된다.
$ sui move build --help
Usage: sui move build [OPTIONS]
Options:
-p, --path <PACKAGE_PATH> Path to a package which the command should be run with respect to
--with-unpublished-dependencies Include the contents of packages in dependencies that haven't been published (only relevant when dumping
bytecode as base64)
--dump-bytecode-as-base64 Whether we are printing in base64
-d, --dev Compile in 'dev' mode. The 'dev-addresses' and 'dev-dependencies' fields will be used if this flag is set. This
flag is useful for development of packages that expose named addresses that are not set to a specific value
--ignore-chain Don't specialize the package to the active chain when dumping bytecode as Base64. This allows building to
proceed without a network connection or active environment, but it will not be able to automatically determine
the addresses of its dependencies
--generate-struct-layouts If true, generate struct layout schemas for all struct types passed into `entry` functions declared by modules
in this package These layout schemas can be consumed by clients (e.g., the TypeScript SDK) to enable
serialization/deserialization of transaction arguments and events
--test Compile in 'test' mode. The 'dev-addresses' and 'dev-dependencies' fields will be used along with any code in
the 'tests' directory
--doc Generate documentation for packages
--install-dir <INSTALL_DIR> Installation directory for compiled artifacts. Defaults to current directory
--force Force recompilation of all packages
--fetch-deps-only Only fetch dependency repos to MOVE_HOME
--skip-fetch-latest-git-deps Skip fetching latest git dependencies
--default-move-flavor <DEFAULT_FLAVOR> Default flavor for move compilation, if not specified in the package's config
--default-move-edition <DEFAULT_EDITION> Default edition for move compilation, if not specified in the package's config
--dependencies-are-root If set, dependency packages are treated as root packages. Notably, this will remove warning suppression in
dependency packages
--silence-warnings If set, ignore any compiler warnings
--warnings-are-errors If set, warnings become errors
--json-errors If set, reports errors at JSON
--no-lint If `true`, disable linters
--lint If `true`, enables extra linters
-h, --help Print help
-V, --version Print version