# Move CLI
The Move command-line interface (Move CLI) is a tool that provides an easy way to interact with Move, to experiment
with writing and running Move code, and to experiment with developing new tools useful
for Move development. To reflect this, the Move CLI commands are grouped into
three main subcommands:
* **package commands**: are commands to create, compile, and test Move packages, as well as perform other operations related to packages. These do not rely on a Move Adapter implementation nor an implementation of storage.
* **sandbox commands**: are commands that allow you to write Move modules and scripts, write and run scripts and tests, and view the resulting state of execution in a local sandboxed environment.
* **experimental commands**: are experimental commands that are currently in development.
Every Move CLI command, with the exception of `package create`, is expected to be run within the context of a [Move package](https://move-language.github.io/move/packages.html).
## Installation
```shell
$ cargo install --path move/language/tools/move-cli
```
or
```shell
$ cargo install --git https://github.com/move-language/move move-cli --branch main
```
This will install the `move` binary in your Cargo binary directory. On
macOS and Linux this is usually `~/.cargo/bin`. You'll want to make sure
this location is in your `PATH` environment variable.
Now you should be able to run the Move CLI:
```shell
$ move
Move 0.1.0
CLI frontend for Move compiler and VM
USAGE:
move [FLAGS] [OPTIONS] <SUBCOMMAND>
...
```
We'll go through the most common Move CLI commands and flags here, however
you can find the complete list of commands available by calling `move
--help`. Additionally, the complete list of flags and options available
for each Move CLI command can be found by passing the `--help` flag to it,
i.e., `move <command> --help`.
## Package Commands
Package commands provide wrappers with sane defaults around other commands
that are provided either by various Move tools, compiler, or prover.
The `move new` command will create a new empty Move package:
```shell
$ 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>
```
From within a package's root directory, you can build the modules and/or scripts that you have written in the package with:
```shell
$ move build # Builds the Move package you are currently in
$ move build -p <path> # Builds the Move package at <path>
```
The compiled artifacts will by default be stored in the `build` directory. You
can change where the build artifacts are saved by passing the optional `--build-dir` flag:
```shell
$ move build --build-dir <path_to_save_to> # Build current Move package and save artifacts under <path_to_save_to>
```
You can verify the specifications in a Move package using the Move Prover with the `prove` command:
```shell
$ move prove # Verify the specifications in the current package
$ move prove -p <path> # Verify the specifications in the package at <path>
```
In order to run the Move Prover [additional tools need to be
installed](https://github.com/move-language/move/blob/main/language/move-prover/doc/user/install.md).
Information on the Move Prover and its configuration options can be found
[here](https://github.com/move-language/move/blob/main/language/move-prover/doc/user/prover-guide.md)
and
[here](https://github.com/move-language/move/blob/main/language/move-prover/doc/user/spec-lang.md).
You can also run unit tests in a package using the `test` command
```shell
$ move test # Run Move unit tests in the current package
$ move test -p <path> # Run Move unit tests in the package at <path>
```
## Sandbox Commands
The sandbox allows you to experiment with writing and running Move code without
validators, a blockchain, or transactions. Persistent data is stored on-disk in
a directory structure that mimics the Move memory model
### Project structure
Each sandbox command is run in the context of a Move package. So let's create a
Move package that we'll use for the code in this README and `cd` into it:
```shell
$ move new readme
$ cd readme
```
### Compiling and running scripts
Let's first start out with a simple script that prints its [`signer`](https://move-language.github.io/move/signer.html).
Create a file named `sources/debug_script.move` and type the following into it:
```rust
// sources/debug_script.move
script {
use std::debug;
fun debug_script(account: signer) {
debug::print(&account)
}
}
```
Before we can run this however, we need to import the Move standard library
nursery in order to have access to the `Debug` module and `Std` [named
address](https://move-language.github.io/move/address.html#named-addresses).
You can specify dependencies locally, or using a Git URL. Here, we will specify
it using Git, so add the following to the `Move.toml` file in the `readme`
directory:
```toml
[addresses]
std = "0x1" # Specify and assign 0x1 to the named address "std"
[dependencies]
MoveNursery = { git = "https://github.com/move-language/move.git", subdir = "language/move-stdlib/nursery", rev = "main" }
# ^ ^ ^ ^
# Git dependency Git clone URL Subdir under git repo (optional) Git revision to use
```
Now let's try running the script -- the very first time may take some time since the package command will clone the repository at the given URL, but subsequent calls should be fast:
```shell
$ move sandbox run sources/debug_script.move --signers 0xf
[debug] (&) { 0000000000000000000000000000000f }
```
The `--signers 0xf` argument indicates which account address(es) have signed
off on the script. Omitting `--signers` or passing multiple signers to this
single-`signer` script will trigger a type error.
### Passing arguments
The CLI supports passing non-`signer` arguments to `move sandbox run` via `--args`. The following argument types are supported:
* `bool` literals (`true`, `false`)
* `u64` literals (e.g., `10`, `58`)
* `address` literals (e.g., `0x12`, `0x0000000000000000000000000000000f`)
* hexadecimal strings (e.g., `'x"0012"'` will parse as the `vector<u8>` value `[00, 12]`)
* ASCII strings (e.g., `'b"hi"'` will parse as the `vector<u8>` value `[68, 69]`)
### Publishing new modules
When executing a transaction script you'll often want to call into different
Move modules, like in the example above with the `Debug` module. New modules can
be added to the `sources` directory in the package where the CLI is being
invoked. You can also add dependencies on other packages to have access to the
modules that they define (just like we did with the `Debug` module above). The
`move sandbox run` command will compile and publish each module in the package, and
in each of the package's transitive dependencies, before running the given script.
Try saving this code in `sources/Test.move`:
```rust
// sources/Test.move
module 0x2::Test {
use std::signer;
struct Resource has key { i: u64 }
public fun publish(account: &signer) {
move_to(account, Resource { i: 10 })
}
public fun write(account: &signer, i: u64) acquires Resource {
borrow_global_mut<Resource>(signer::address_of(account)).i = i;
}
public fun unpublish(account: &signer) acquires Resource {
let Resource { i: _ } = move_from(signer::address_of(account));
}
}
```
Now, try
```shell
$ move build
```
This will cause the CLI to compile and typecheck the modules under
`sources`, but it won't publish the module bytecode under `storage`. You can
compile and publish the module by running the `move sandbox publish` command
(here we pass the `-v` or verbose flag to get a better understanding of what's
happening):
```shell
$ move sandbox publish -v
Found 1 modules
Publishing a new module 000000000000000000000000000
没有合适的资源?快使用搜索试试~ 我知道了~
Web 开发工具包:现代化 Web 应用程序开发工具包旨在帮助开发人员更快地构建现代化的 Web 应用程序
共2000个文件
md:336个
ts:329个
txt:304个
0 下载量 113 浏览量
2024-03-20
11:25:05
上传
评论
收藏 53.13MB ZIP 举报
温馨提示
现代化 Web 应用程序开发工具包旨在帮助开发人员更快地构建现代化的 Web 应用程序。它提供了一套完整的组件库、构建工具和最佳实践,使开发人员能够以高效和可维护的方式构建用户友好的 Web 应用。SUI 提供了丰富的功能和灵活的设计选项,帮助开发人员快速启动项目并提供卓越的用户体验。
资源推荐
资源详情
资源评论
收起资源包目录
Web 开发工具包:现代化 Web 应用程序开发工具包旨在帮助开发人员更快地构建现代化的 Web 应用程序 (2000个子文件)
__init__ 0B
prettier.config.cjs 119B
prettier.config.cjs 82B
prettier.config.cjs 82B
CODEOWNERS 1KB
config 1KB
custom.css 8KB
index.module.css 4KB
index.css 3KB
fonts.css 3KB
TransactionResult.module.css 2KB
ObjectView.module.css 2KB
index.css 1KB
ModuleView.module.css 1KB
styles.module.css 1KB
index.module.css 1KB
cookieConsent.css 779B
styles.css 607B
TxForID.module.css 447B
styles.module.css 337B
index.css 328B
styles.module.css 315B
base.css 248B
styles.module.css 200B
styles.module.css 168B
styles.module.css 147B
styles.module.css 138B
styles.module.css 136B
index.css 59B
Dockerfile 2KB
Dockerfile 2KB
Dockerfile 1KB
Dockerfile 1KB
Dockerfile 1KB
Dockerfile 966B
Dockerfile 958B
Dockerfile 929B
Dockerfile 773B
.dockerignore 113B
diagram.drawio 7KB
.eslintignore 19B
.env.example 273B
.gitattributes 506B
.gitignore 2KB
.gitignore 2KB
.gitignore 514B
.gitignore 110B
.gitignore 62B
.gitignore 55B
.gitignore 18B
.gitignore 18B
.gitkeep 0B
transactions.graphql 5KB
objects.graphql 3KB
checkpoint.graphql 2KB
getNormalizedMoveModule.graphql 2KB
getCurrentEpoch.graphql 1KB
getLatestSuiSystemState.graphql 1KB
stakes.graphql 890B
getDynamicFieldObject.graphql 886B
devInspectTransactionBlock.graphql 761B
getDynamicFields.graphql 639B
queryEvents.graphql 638B
getNormalizedMoveFunction.graphql 541B
getNormalizedMoveStruct.graphql 516B
executeTransactionBlock.graphql 510B
getCoins.graphql 491B
nameService.graphql 435B
dryRunTransactionBlock.graphql 430B
getCommitteeInfo.graphql 365B
getNormalizedMoveModulesByPackage.graphql 363B
getAllBalances.graphql 361B
getMoveFunctionArgTypes.graphql 359B
getValidatorsApy.graphql 286B
getBalance.graphql 271B
getProtocolConfig.graphql 267B
getCoinMetadata.graphql 220B
getTotalSupply.graphql 178B
getTotalTransactionBlocks.graphql 153B
getLatestCheckpointSequenceNumber.graphql 151B
getReferenceGasPrice.graphql 136B
getChainIdentifier.graphql 119B
index.html 1KB
index.html 1KB
index.html 1KB
index.html 919B
index.html 372B
index.html 306B
index.html 299B
index.template.html 288B
index.html 283B
index.html 251B
preview-head.html 44B
favicon.ico 918B
index.js 21KB
index.js 14KB
result.js 10KB
prism-move.js 8KB
index.js 8KB
.eslintrc.js 7KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
UnknownToKnown
- 粉丝: 1w+
- 资源: 550
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功