Skip to content

Reorgnaize CLI index, add links, and surface generate #1403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/build/getting-started/flow-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ You can't deploy the same contract to multiple accounts at the same time with th

:::

## Running Scripts
## Creating Scripts

Scripts are used to read data from the Flow blockchain. There is no state modification. In our case, we are going to read a greeting from the `HelloWorld` contract.

Expand All @@ -170,7 +170,9 @@ If we wanted to generate a new script, we could run:
flow generate script ScriptName
```

But the default project already has a `GetCounter` script for reading the count of the `Counter` contract. Open `cadence/scripts/GetCounter.cdc` in your editor to see the script.
## Running Scripts

The default project already has a `GetCounter` script for reading the count of the `Counter` contract. Open `cadence/scripts/GetCounter.cdc` in your editor to see the script.

To run the script, you can run:

Expand Down
11 changes: 6 additions & 5 deletions docs/tools/flow-cli/boilerplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_position: 16

## Introduction

Flow CLI now includes a feature to automatically generate boilerplate code for contracts, transactions, and scripts. This feature enhances the development experience by simplifying the initial setup of various components in Flow.
Flow CLI includes a feature to automatically generate boilerplate code for contracts, transactions, and scripts. This feature enhances the development experience by simplifying the initial setup of various components in Flow.

```shell
> flow generate
Expand All @@ -23,7 +23,7 @@ Available Commands:
transaction Generate a new transaction
```

## Generate Contract
## Create a Contract

To create a new contract with basic structure, use the `contract` command. It creates a new Cadence file with a template contract definition.

Expand All @@ -45,7 +45,7 @@ access(all) contract HelloWorld {
}
```

## Generate Transaction
## Create a Transaction

For initializing a transaction, use the `transaction` command. It sets up a new Cadence file with a template transaction structure.

Expand All @@ -69,7 +69,9 @@ transaction() {
}
```

## Generate Script
It also adds the new contract to `flow.json`.

## Create a Script

Similarly, to start a new script, the `script` command generates a Cadence file with a basic script structure.

Expand Down Expand Up @@ -101,4 +103,3 @@ The `--dir` flag is an optional feature in the Flow CLI `generate` commands, all
- **Example**: `flow generate contract HelloWorld --dir=custom_contracts`

Use the `--dir` flag only if your project requires a different organizational structure than the default.

82 changes: 72 additions & 10 deletions docs/tools/flow-cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,69 @@ sidebar_position: 3

The **Flow Command Line Interface (CLI)** is a powerful tool that enables developers to seamlessly interact with the Flow blockchain across various environments, including testnet, mainnet, and local development using the Flow Emulator. Designed for ease of use, the Flow CLI simplifies common blockchain tasks such as managing accounts and contract dependencies, sending transactions, querying chain state, deploying smart contracts, and much more.

## Basic Usage

The Flow CLI is essential for developers looking to build, test, and maintain decentralized applications on the Flow blockchain efficiently, offering a feature-rich, user-friendly interface for both beginners and experienced blockchain developers.

With Flow CLI, developers can:

- **Initialize Projects**: Quickly set up new Flow projects using the `flow init` command, which creates the necessary files and directories, sets up your project configuration, and installs any core contract dependencies.
- **Manage Contract Dependencies**: Use the [Dependency Manager](dependency-manager.md) to install and manage smart contract dependencies effortlessly, simplifying the integration of external contracts into your project.
- **Manage Accounts**: Create and manage Flow accounts, configure keys, and handle account-related operations.
- **Send Transactions**: Build, sign, and submit transactions to the Flow network, allowing for contract interaction and fund transfers.
- **Query Chain State**: Retrieve data from the Flow blockchain, including account balances, event logs, and the status of specific transactions.
- **Deploy Smart Contracts**: Easily deploy and update Cadence smart contracts on any Flow environment (emulator, testnet, or mainnet).
- **Use the Emulator:** Set up a local Flow blockchain instance with the Flow emulator to test and debug smart contracts in a development environment before deploying them on the network.
- **Interact with the [Flow Access API](/http-api)**: Automate complex workflows using configuration files and command-line scripting, which allows for greater flexibility in continuous integration (CI) or custom development tools.
- **Access Flow’s Tooling Ecosystem**: Integrate Flow CLI with other developer tools like the [Cadence Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=onflow.cadence) to enhance your development experience.
### Initialize Projects

The Flow CLI is essential for developers looking to build, test, and maintain decentralized applications on the Flow blockchain efficiently, offering a feature-rich, user-friendly interface for both beginners and experienced blockchain developers.
Quickly set up new Flow projects using the [`flow init`] command, which creates the necessary files and directories, sets up your project configuration, and installs any core contract dependencies.

### Manage Contract Dependencies

Use the [Dependency Manager] to install and manage smart contract dependencies effortlessly, simplifying the integration of external contracts into your project.

### Manage Accounts

Create and manage Flow [accounts], configure keys, and handle account-related operations.

### Send Transactions

Build, sign, and submit [transactions] to the Flow network, allowing for contract interaction and fund transfers.

### Query Chain State with Scripts

Use [scripts] to retrieve data from the Flow blockchain, including account balances, event logs, and the status of specific transactions.

### Deploy Smart Contracts

Easily deploy and update Cadence smart contracts on any Flow environment (emulator, testnet, or mainnet).

### Use the Emulator

Set up a local Flow blockchain instance with the Flow [emulator] to test and debug smart contracts in a development environment before deploying them on the network.

### Interact with the Flow Access API

With the [Flow Access API](/http-api), you can automate complex workflows using configuration files and command-line scripting, which allows for greater flexibility in continuous integration (CI) or custom development tools.

### Access Flow's Tooling Ecosystem

Integrate Flow CLI with other developer tools like the [Cadence Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=onflow.cadence) to enhance your development experience.

### Create Contracts, Transactions, and Scripts

You can create contract, transaction, and script [boilerplate] stubs with the CLI. Doing so for contracts automatically adds them to `flow.json`.

```zsh
flow generate contract [ContractName]
flow generate transaction [TransactionName]
flow generate script [ScriptName]
```

### Add Existing Contracts

You can also [manage configuration] to add existing files to `flow.json`.

```zsh
flow config add [ContractName]
```

### Advanced Dependency Management

Manage both local and remote smart contract dependencies with the [dependency manager].

## Installation

Expand All @@ -28,3 +78,15 @@ macOS, Linux, and Windows.
## Create Your First Project

To get started with creating your first Flow project and to learn more about how to use the Flow CLI super commands, please refer to the [Super Commands documentation](super-commands.md). These commands simplify the setup and development process, allowing you to focus on building your application without worrying about the underlying configurations.

<!-- Reference-style links, will not render on page -->

[`flow init`]: ./super-commands.md#init
[Dependency Manager]: ./dependency-manager.md
[accounts]: ./accounts/get-accounts.md
[transactions]: ./transactions/send-transactions.md
[scripts]: ./scripts/execute-scripts.md
[emulator]: ../emulator/index.md
[boilerplate]: ./boilerplate.md
[manage configuration]: ./flow.json/manage-configuration.md
[dependency manager]: ./dependency-manager.md