Flow CLI Super Commands

Flow CLI Super Commands

An introduction tutorial to Flow Command-Line Interface (CLI) super commands.

·

6 min read

Introduction to Flow CLI Super Commands

In this tutorial, we’ll cover how to use the Flow Command-Line Interface (CLI) super commands setup and dev.

In January 2023, the Flow team introduced a new set of commands, setup and dev. The goal was to make creating new projects and developing contracts easier.

⚠️ The commands are intended to be used during the development phase of your project and are unable to interact with testnet or mainnet.

Pre-requirement

Before we get started, let’s make sure that you have the Flow CLI installed.

Head to your terminal and enter the following command:

flow version

If you already have the Flow CLI installed, the Version will be returned. If not, you can install the CLI here.

Once you have the CLI installed, we’ll dive into the 2 new commands.


Setup Super Command

The first command is the setup command.

The setup command can be used to create a new project. It includes a basic folder structure and a flow.json file. There’s also an option to use —scaffolds but more on this later!

To create a new project, navigate to where you’ll create your project and enter the following command:

flow setup <Project Name>

Once complete, you will receive a 🎉 Congrats message with steps to get started:

🎉 Congrats! your project was created.

Start development by following these steps:
1. 'cd <Project Name>' to change to your new project,
2. 'flow emulator' to start a Flow emulator,
3. 'flow dev' to start developing.

You should also read README.md to learn more about the development process!

If you navigate inside your project, there will be three items:

  1. README.md - provides an overview of the development process

  2. Cadence folder - Inside this folder, you will find 4 additional folders: contracts, scripts, transactions, and test

  3. flow.json - configuration file

But what about the scaffolds?

setup --scaffold

As I mentioned earlier, there’s also the option to use a scaffold.

To use a scaffold, navigate to where you’ll create your project and enter the following command:

flow setup <Project Name> --scaffold

You’ll be greeted with a prompt to select the scaffold that you would like to use:

Use the arrow keys to navigate: ↓ ↑ → ←
? Which scaffold would you like to use:
  ▸ Empty Cadence Project - Empty project containing only basic folder structure and flow.json configuration.
    Simple Cadence Project - Scaffold contains required folder structure as well as some example Cadence code.
    Web Dapp using FCL - Simple demo application using next.js and FCL with provided Cadence contracts.
    Simple Unity - Simple example demonstrating how to interact with the Flow network using Unity SDK.
    Mobile Unity Game - Example words game built on Flow using the Unity SDK.
    Swift iOS simple example - iOS example demonstrating usage of FCL and Flow interactions.
    Android simple example - Android example demonstrating usage of FCL and Flow interactions.

Select the scaffold that you want to use for your project.

Once complete, you’ll receive a 🎉 Congrats message with the scaffold you selected at the top and steps to get started:

✔ Simple Cadence Project - Scaffold contains required folder structure as well as some example Cadence code.

🎉 Congrats! your project was created.

Start development by following these steps:
1. 'cd <Project Name>' to change to your new project,
2. 'flow emulator' to start a Flow emulator,
3. 'flow dev' to start developing.

You should also read README.md to learn more about the development process!

If you would like to contribute to the scaffolds list, you can do so here.

Now that you know how to set up your next project, let’s take a look at the second super command dev.

Dev Super Command

The dev command is used to monitor Cadence files that are added, deploy them on the emulator and update the flow.json file for you.

So how does dev work?

Once your project is set up using the setup command, you will need to start the emulator in your project's directory.

Navigate to the directory and use flow emulator, or flow emulator -v for verbose logging, to start the emulator.

In a new terminal, navigate to your projects directory and use the flow dev command.

flow dev will now monitor your files, automatically sync them with the contracts on the emulator and update your flow.json file for you!

And that’s it 👏 You have successfully used super commands!


Import Schema

Another change that was made with the super commands release, was how contracts are imported.

Now, you can import contracts by simply using import "{Contract Name}":

import "HelloWorld"

Lastly, don’t forget the help command.

A command that’s often overlooked is the flow help command. If you get stuck using the Flow CLI, you can always reference help.

For help with super commands and any other Flow CLI commands, you can use flow [command] --help.

Usage:
  flow [command]

👋 Welcome Flow developer!
   If you are starting a new flow project use our super commands, start by running 'flow setup'.

🔥 Super Commands
  dev          Build your Flow project
  setup        Start a new Flow project

📦 Flow Entities
  accounts     Create and retrieve accounts and deploy contracts
  blocks       Retrieve blocks
  collections  Retrieve collections
  events       Retrieve events

💬 Flow Interactions
  scripts      Execute Cadence scripts
  transactions Build, sign, send and retrieve transactions

🔨 Flow Tools
  cadence      Execute Cadence code
  dev-wallet   Run a development wallet
  emulator     Run Flow network for development
  flowser      Run Flowser project explorer
  test         Run Cadence tests

🏄 Flow Project
  deploy       Deploy all project contracts
  init         Initialize a new configuration
  project      Manage your Cadence project
  run          Start emulator and deploy all project contracts

🔒 Flow Security
  keys         Generate and decode Flow keys
  signatures   Signature verification and creation

Additional Commands:
  completion   Generate the autocompletion script for the specified shell
  config       Utilities to manage configuration
  help         Help about any command
  settings     Manage persisted global settings
  snapshot     Retrieve the protocol state snapshot
  status       Display the status of the Flow network
  version      View version and commit information

Flags:
  -f, --config-path strings   Path to flow configuration file (default [/home/amethyst/flow.json,flow.json])
  -x, --filter string         Filter result values by property name
  -h, --help                  help for flow
      --host string           Flow Access API host address
  -l, --log string            Log level, options: "debug", "info", "error", "none" (default "info")
  -n, --network string        Network from configuration file (default "emulator")
      --network-key string    Flow Access API host network key for secure client connections
  -o, --output string         Output format, options: "text", "json", "inline" (default "text")
  -s, --save string           Save result to a filename
      --skip-version-check    Skip version check during start up
  -y, --yes                   Approve any prompts

Use "flow [command] --help" for more information about a command.

Thanks for reading! Hope this brief super commands tutorial was helpful! Feel free to share and connect here or on Twitter 😀

If you have questions or comments, you can leave them below or hop into the Flow Discord and ask in the developers channel.

Did you find this article valuable?

Support Amethyst by becoming a sponsor. Any amount is appreciated!