Skip to content

Getting Started with Console

The Console module is provided as a part of Vapor's Console package (vapor/console). This module provides APIs for performing console I/O including things like outputting stylized text, requesting user input, and displaying activity indicators like loading bars.

Tip

For an in-depth look at all of Console's APIs, check out the Console API docs.

Usage

This package is included with Vapor and exported by default. You will have access to all Console APIs when you import Vapor.

import Vapor // implies import Console

Standalone

The Console module, part of the larger Vapor Console package, can also be used on its own with any Swift project.

To include it in your package, add the following to your Package.swift file.

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "Project",
    dependencies: [
        ...
        /// 💻 APIs for creating interactive CLI tools.
        .package(url: "https://github.com/vapor/console.git", from: "3.0.0"),
    ],
    targets: [
      .target(name: "Project", dependencies: ["Console", ... ])
    ]
)

Use import Console to access the APIs.

Overview

Continue to Console → Overview for an overview of Console's features.