Move 命令行界面(Move CLI)是一种工具,它提供了一种与 Move 交互、测试编写和运行 Move 代码以及测试开发对 Move 开发有用的新工具的简单方法。
Move 命令行界面(Move CLI)是一种工具,它提供了一种与 Move 交互、测试编写和运行 Move 代码以及测试开发对 Move 开发有用的新工具的简单方法。
macOS 和 Linux:
cargo install --git https://github.com/move-language/move move-cli --branch main
现在,您应该能够运行Move CLI:
我们将在此处介绍最常见的 Move CLI 命令和标志,但是您可以通过调用 找到可用的命令的完整列表。此外,通过将标志传递给每个 Move CLI 命令,可以找到可用于每个 Move CLI 命令的标志和选项的完整列表,即 move --help --help move <command> --help
创建一个新项目的命令:move new
move new <package_name> # Create a Move package <package_name> under the current dir
move new <package_name> -p <path> # Create a Move package <package_name> under path <path>
my-move
├─ Move.toml
└─ sources
官方配置清单
[package]
name = <string> # e.g., "MoveStdlib"
version = "<uint>.<uint>.<uint>" # e.g., "0.1.1"
license* = <string> # e.g., "MIT", "GPL", "Apache 2.0"
authors* = [<string>] # e.g., ["Joe Smith (joesmith@noemail.com)", "Jane Smith (janesmith@noemail.com)"]
[addresses] # (Optional section) Declares named addresses in this package and instantiates named addresses in the package graph
# One or more lines declaring named addresses in the following format
<addr_name> = "_" | "<hex_address>" # e.g., Std = "_" or Addr = "0xC0FFEECAFE"
[dependencies] # (Optional section) Paths to dependencies and instantiations or renamings of named addresses from each dependency
# One or more lines declaring dependencies in the following format
<string> = { local = <string>, addr_subst* = { (<string> = (<string> | "<hex_address>"))+ } } # local dependencies
<string> = { git = <URL ending in .git>, subdir=<path to dir containing Move.toml inside git repo>, rev=<git commit hash>, addr_subst* = { (<string> = (<string> | "<hex_address>"))+ } } # git dependencies
[dev-addresses] # (Optional section) Same as [addresses] section, but only included in "dev" and "test" modes
# One or more lines declaring dev named addresses in the following format
<addr_name> = "_" | "<hex_address>" # e.g., Std = "_" or Addr = "0xC0FFEECAFE"
[dev-dependencies] # (Optional section) Same as [dependencies] section, but only included in "dev" and "test" modes
# One or more lines declaring dev dependencies in the following format
<string> = { local = <string>, addr_subst* = { (<string> = (<string> | <address>))+ } }
项目信息
[package]
name = "my-move"
version = "0.0.0"
Move标准库地址
[dependencies]
MoveStdlib = { git = "https://github.com/move-language/move.git", subdir = "language/move-stdlib", rev = "main" }
模块命名(方便项目直接引用)
[addresses]
std = "0x1"
由于生成项目默认给的Move标准库是Git地址很慢,可以从https://github.com/diem/diem/tree/latest/language/move-stdlib下载Move的标准库放到本地。
大家也可以使用aptos项目整理好的库https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/framework,下载aptos-stdlib,move-stdlib
两个包放在项目同目录
[package]
name = "my-move"
version = "0.0.0"
[addresses]
std = "0x1"
[dependencies]
AptosStdlib = { local = "../aptos-stdlib" }
MoveStdlib = { local = "../move-stdlib" }
sources目录创建一个名为debug_script.move的文件,并在其中输入以下内容:
// sources/debug_script.move
script {
use std::debug;
fun debug_script(account: signer) {
debug::print(&account)
}
}
move sandbox run sources/debug_script.move --signers 0xf
[debug] (&) { 0000000000000000000000000000000F }
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!