<a id="exp-cli"></a>

# Command-line tools

**Workshop** works through four command-line tools,
each aimed at a different audience and stage of the workflow.
**workshop** and **sdk**
are the everyday tools for people working in workshops.
**sdkcraft**, shipped as its own snap,
is the SDK-author tool that publishers run on their workstation.
**workshopctl** is an in-workshop helper
that SDK hooks invoke to report state back to the daemon.

<a id="exp-workshop-cli"></a>

## workshop

<!-- @artefact workshop (CLI) -->
<!-- @artefact workshopd -->

**workshop** is the daily go-to instrument for regular users,
with a set of commands that govern the entire lifecycle of a
[workshop](https://ubuntu.com/workshop/docs//explanation/index.md#exp-workshop).

There are several categories of commands that vary by their purpose:

| Actions                | Commands                                                                                                | What they do                                                                                                                                      |
|------------------------|---------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| Create, update, delete | **init**,<br/>**launch**,<br/>**refresh**,<br/>**remove**,<br/>**restore**,<br/>**start**,<br/>**stop** | Create a workshop definition,<br/>then govern the workshop’s existence and runtime state,<br/>from first launch to refresh, restore, and removal. |
| Customize              | **sketch-sdk**,<br/>**sketches**                                                                        | Augment a workshop with project-specific customizations<br/>through sketch SDKs.                                                                  |
| Enumerate              | **info**,<br/>**list**                                                                                  | List the workshops in a project and inspect their current details.                                                                                |
| Track changes          | **changes**,<br/>**tasks**                                                                              | Review recent changes to the workshops in a project<br/>and the tasks that make up each change.                                                   |
| Manage connections     | **connect**,<br/>**connections**,<br/>**disconnect**,<br/>**remount**                                   | Wire interface plugs and slots between SDKs,<br/>list existing connections, and remount their sources.                                            |
| Run shell commands     | **exec**,<br/>**shell**                                                                                 | Run an ad-hoc command in a workshop<br/>or open an interactive shell inside it.                                                                   |
| Run named actions      | **actions**,<br/>**run**                                                                                | List and invoke the named actions<br/>defined in a workshop’s `actions:` section.                                                                 |
| Manage warnings        | **okay**,<br/>**warnings**                                                                              | List warnings raised by the daemon and acknowledge them.                                                                                          |

#### NOTE
**workshop** talks to the **Workshop** daemon,
**workshopd**, via a REST API,
so alternatives are possible and, in fact, encouraged.

<a id="exp-sdk-cli"></a>

## sdk

<!-- @artefact sdk (CLI) -->

**sdk** makes it easy to find and learn more about
the SDKs available to you.
Like **workshop**,
it talks to the **Workshop** daemon,
**workshopd**, over a REST API.

There is one category of commands:

| Actions   | Commands                             | What they do                                                                                           |
|-----------|--------------------------------------|--------------------------------------------------------------------------------------------------------|
| Discover  | **find**,<br/>**info**,<br/>**list** | Search the SDK Store,<br/>enumerate the SDKs available on your machine,<br/>and inspect their details. |

<a id="exp-sdkcraft-cli"></a>

## sdkcraft

<!-- @artefact sdkcraft (CLI) -->

**sdkcraft** is what an SDK publisher uses on their workstation
to scaffold, build, test, try, and publish SDKs to the SDK Store.

There are several categories of commands that vary by their purpose:

| Actions       | Commands                                                                                                      | What they do                                                                                                         |
|---------------|---------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| Lifecycle     | **build**,<br/>**clean**,<br/>**pack**,<br/>**prime**,<br/>**pull**,<br/>**stage**,<br/>**test**,<br/>**try** | Work through the parts-based build pipeline<br/>to produce an SDK artefact<br/>and try it locally before publishing. |
| Store         | **create-track**,<br/>**register**,<br/>**release**,<br/>**revisions**,<br/>**upload**                        | Claim an SDK name, manage its tracks, upload artefacts,<br/>and list or release revisions to channels.               |
| Store account | **login**,<br/>**whoami**                                                                                     | Authenticate against the SDK Store<br/>and inspect the active identity.                                              |
| Other         | **init**,<br/>**version**                                                                                     | Bootstrap a new project layout<br/>and report the installed **SDKcraft** version.                                    |

#### NOTE
**SDKcraft** is a separate snap, installed independently of **Workshop**.
See the [SDKcraft](https://github.com/canonical/sdkcraft/) repository for installation and release notes.

<a id="exp-workshopctl-cli"></a>

## workshopctl

<!-- @artefact workshopctl -->
<!-- @artefact SDK hook -->

**workshopctl** reports SDK state back to the **Workshop** daemon
over a restricted socket.
[SDK hooks](https://ubuntu.com/workshop/docs//explanation/sdks/runtime-hooks.md#exp-sdk-hooks) invoke it from inside a running workshop;
it is not intended for end users to call directly.

There is one category of commands:

| Actions           | Commands       | What they do                                                                                                                                                             |
|-------------------|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Report SDK health | **set-health** | Let the daemon know whether the SDK is `okay`,<br/>`waiting`, or in an `error` state,<br/>with an optional machine-readable error code<br/>and a human-readable message. |

#### NOTE
**workshopctl** only works from an SDK hook context,
where the daemon supplies a context cookie via the
`WORKSHOP_COOKIE` environment variable.
Running it from an interactive shell returns
`cannot invoke workshopctl operation commands ... from outside of a workshop`.

## See also

Reference:

- [Command-line tools](https://ubuntu.com/workshop/docs//reference/index.md#ref-cli)
- [SDK hooks](https://ubuntu.com/workshop/docs//reference/sdks.md#ref-sdk-hooks)

Tutorial:

- [Get started with workshops](https://ubuntu.com/workshop/docs//tutorial/part-1-get-started.md#tut-get-started)
