Skip to content

Commit

Permalink
[CLI] Better manifest, more comments, more love (MystenLabs#16191)
Browse files Browse the repository at this point in the history
## Description 

Move.toml now features hints on which fields to use and how.

## Test Plan 

Simple feature, only adds comments. Grammar tested with ChatGPT.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes

- Move.toml is now more dev-friendly offering hints and usage examples
  • Loading branch information
damirka authored Feb 14, 2024
1 parent 9495851 commit 20b637f
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 9 deletions.
3 changes: 0 additions & 3 deletions crates/sui-framework/packages/sui-framework/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ version = "0.0.1"
published-at = "0x2"

[dependencies]
# Using a local dep for the Move stdlib instead of a git dep to avoid the overhead of fetching the git dep in
# CI. The local dep is an unmodified version of the upstream stdlib
MoveStdlib = { local = "../move-stdlib" }
#MoveStdlib = { git = "https://github.com/diem/diem.git", subdir="language/move-stdlib", rev = "346301f33b3489bb4e486ae6c0aa5e030223b492" }

[addresses]
sui = "0x2"
51 changes: 45 additions & 6 deletions external-crates/move/crates/move-cli/src/base/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,66 @@ impl New {
create_dir_all(path.join(SourcePackageLayout::Sources.path()))?;
let mut w = std::fs::File::create(path.join(SourcePackageLayout::Manifest.path()))?;
writeln!(
&mut w,
"[package]
name = \"{name}\"
w,
r#"[package]
name = "{name}"
# edition = "2024.alpha" # To use the Move 2024 edition, currently in alpha
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]
[dependencies]"
[dependencies]"#
)?;
for (dep_name, dep_val) in deps {
writeln!(w, "{dep_name} = {dep_val}")?;
}

writeln!(
w,
"
[addresses]"
r#"
# For remote import, use the `{{ git = "...", subdir = "...", rev = "..." }}`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = {{ git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }}
# For local dependencies use `local = path`. Path is relative to the package root
# Local = {{ local = "../path/to" }}
# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = {{ local = "../conflicting/version", override = true }}
[addresses]"#
)?;

// write named addresses
for (addr_name, addr_val) in addrs {
writeln!(w, "{addr_name} = \"{addr_val}\"")?;
}

writeln!(
w,
r#"
# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"
[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = {{ local = "../path/to/dev-build" }}
[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"
"#
)?;

// custom addition in the end
if !custom.is_empty() {
writeln!(w, "{}", custom)?;
}

Ok(())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,74 @@ External Command `cat P1/Move.toml`:
[package]
name = "P1"

# edition = "2024.alpha" # To use the Move 2024 edition, currently in alpha
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]

# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# For local dependencies use `local = path`. Path is relative to the package root
# Local = { local = "../path/to" }

# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = { local = "../conflicting/version", override = true }

[addresses]

# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"

[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = { local = "../path/to/dev-build" }

[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"

Command `new P2 -p other_dir`:
External Command `cat other_dir/Move.toml`:
[package]
name = "P2"

# edition = "2024.alpha" # To use the Move 2024 edition, currently in alpha
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]

# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# For local dependencies use `local = path`. Path is relative to the package root
# Local = { local = "../path/to" }

# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = { local = "../conflicting/version", override = true }

[addresses]

# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"

[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = { local = "../path/to/dev-build" }

[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"

0 comments on commit 20b637f

Please sign in to comment.