Introducing the State Tool (Beta)

What is the State Tool?

The State Tool is the command line interface (CLI) for the ActiveState Platform. It allows you to manage and use Platform projects right from the command prompt. You can create new projects, view existing projects, and download and install language runtime environment. A runtime environment is the programming language and set of packages, or modules, you need for your coding project.

The State Tool provides you with tools to automate all of the tedious configuration workflow involved in setting up and running a coding project. It also allows any developer you share the project with to run a single command and start contributing code instead of trying to get up and running by following a mulit-step README document.

What is the workflow for using the State Tool?

The first step is to create a Project on the ActiveState Platform, or select an exist public project to use. You create the project in the ActiveState Platform Dashboard, or directly in the State Tool, and the Platform resolves the language dependancies and builds a runtime environment.

The second step is to “activate” your project. It’s as simple as running state activate <owner>/<project_name>. After your project successfully builds on the Platform, you can instantly deploy your runtime environment locally using the State Tool. Activating a project with the State Tool creates a virtual environment and will not contaminate any of the preexisting Python installations or environments you have configured.

Whenever your project is activated, your shell will be configured to use the runtime environment you created on the ActiveState Platform. Any preexisting language installations (Perl, Python, etc.) on your computer will be overridden only while using the “activated state”.

There are two ways you can work with and configure your project:

  1. You can enter commands and subcommands using state [command] on the command line. You can learn the State Tool command line interactively using the --help flag. Help is provided for each command and subcommand, and you can explore the hierarchy of commands until you find what you need. You can also browse the command reference to find the information you need.

    For example, the following commands provide increasing detail about the state secrets set subcommand:

    # list information about the available commands
    state --help
    # show details for the secrets command
    state secrets --help
    # show details for the set subcommand
    state secrets set --help
  2. You can customize your configuration by editing the activestate.yaml configuration file in your project’s root directory. The State Tool provides a number of ways to configure your ActiveState Platform project to integrate it with your development environment. You can use the following mechanisms to customize the configuration of your project:

    • Constants: Define constant values that can be reused throughout your configuration file. For example, you can define a hostname that’s used repeatedly as a constant and then use the constant name for subsequent references.
    • Secrets: Securely save and retrieve sensitive values for use in your configuration file, either at the project or user level.
    • Scripts: Name and define scripts that you can run within your project by typing the name of the script.
    • Events: Run scripts or commands when particular State Tool events occur. For example, you can hook into the State Tool ACTIVATE event to start up the database server for your development environment.