Skip to content

Commit

Permalink
Merge pull request #28 from mittwald/feature/cli
Browse files Browse the repository at this point in the history
Add section on CLI tool
  • Loading branch information
martin-helmich authored Jul 28, 2023
2 parents 577d9b8 + cd5e369 commit 0851a50
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 0 deletions.
105 changes: 105 additions & 0 deletions docs/api/sdks/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: Using the mittwald CLI
sidebar_label: CLI
description: An introduction on how to use the mittwald command-line interface (CLI)
---

:::danger

Please note that the CLI is currently in an experimental state, and may change without prior notice. We're happy to receive feedback and feature requests via [GitHub issues](https://github.com/mittwald/cli/issues).

:::

## Installing

### Any OS, using NPM

With a local Node.js installation, you can install the mittwald CLI using NPM:

```
$ npm install -g @mittwald/cli
$ mw --help
```

### macOS, using the installer package

Retrieve the latest release package (`*.pkg` file) from our [releases page](https://github.com/mittwald/cli/releases), and run the installer. Pay attention to the processor architecture, and load the `mw-*-arm64.pkg` file when you're using an ARM Mac, and the `mw-*-amd64.pkg` file when using an Intel Mac.

### macOS, using Homebrew

```
$ brew tap mittwald/cli
$ brew install mittwald-cli
$ mw --help
```

### Windows, using the installer package

Retrieve the latest release package (`*.exe` file) from our [releases page](https://github.com/mittwald/cli/releases), and run the installer.

### Using Docker

```
$ export MITTWALD_API_TOKEN=xxx
$ docker run \
--rm \
-it \
-e MITTWALD_API_TOKEN \
mittwald/cli --help
```

## Authenticating

To use the CLI, you first need to authenticate your client using an API token. Have a look at the ["Obtaining an API token" section](../../intro#obtaining-an-api-token) of the introduction for details on how to obtain an API token.

:::note

Additional authentication mechanisms (like an OAuth2 flow in which you can use your browser to authenticate) are planned for the future.

:::

Having a token, you can authenticate like this:

```
$ mw login token
Enter your mStudio API token: ********
```

For non-interactive usage (for example in CI/CD pipelines), you can also pass the token via the `MITTWALD_API_TOKEN` environment variable:

```
$ export MITTWALD_API_TOKEN=********
$ mw login status
```

## General usage

### Project/Server/Organization contexts

Many commands of the CLI act in the context of a certain project, server or organization, and as such require a `--project-id`, `--server-id` or `--org-id` flag. You can either pass these flags to each command, or set them globally using the `mw context` command:

```bash
$ mw context set --project-id=...
$ mw project set --server-id=...
$ mw project set --org-id=...
```

Some commands that _create_ one of these resources also have a `--update-context` flag that will automatically set the context to the newly created resource:

```bash
$ mw project create --description="..." --update-context
```

### Non-interactive usage

If you intend to use `mw` non-interactively (for example in scripts, or CI/CD pipelines), many commands support a `--output|-o` flag that allows you to specify the output format. The default is `text`, which is a human-readable format, but you can also use `json` to get machine-readable output, which you can then easily process using tools like `jq`:

```bash
PROJECT_ID=$(mw project get -ojson | jq -r '.id')
```

Many mutating commands also print progress information about long-running operations. To suppress this output, you can use the `--quiet|-q` flag. In these cases, most commands will fall back to printing the ID of the created resource, which you can then use to retrieve the full resource information:

```bash
PROJECT_ID=$(mw project create --quiet --description="...")
```
10 changes: 10 additions & 0 deletions docs/technologies/databases/redis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ Setting up Redis is easy. However, depending on the CMS or shop system you use,

First, create a Redis database in the mStudio, the management environment of your Space Server or proSpace. You will then find both the host and port in the details under connection information. You need both for the configuration of your system.

### Using the CLI

To create a Redis database via the CLI, use the following command:

```shell
$ mw database redis create --description "My Redis database" --version 7.0
```

The output of this command will print the ID of the newly created database, and also the connection information for the database.

### Using the API

You can also create a Redis database via the API. To do this, read the article ["Creating a Redis database"](../../../api/howtos/create-redis).
Expand Down
99 changes: 99 additions & 0 deletions i18n/de/docusaurus-plugin-content-docs/current/api/sdks/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: Verwendung der mittwald CLI
sidebar_label: CLI
description: Eine Einführung in die Verwendung der mittwald-Befehlszeilenschnittstelle (CLI)
---

## Installation

### Jedes Betriebssystem, mit NPM

Mit einer lokalen Node.js-Installation kannst du die mittwald CLI mit NPM installieren:

```
$ npm install -g @mittwald/cli
$ mw --help
```

### macOS, mit dem Installationspaket

Lade das neueste Installationspaket (`*.pkg`-Datei) von unserer [Releases-Seite](https://github.com/mittwald/cli/releases) herunter und führe den Installer aus. Achte auf die Prozessorarchitektur und lade die `mw-*-arm64.pkg`-Datei, wenn du einen ARM-Mac verwendest, und die `mw-*-amd64.pkg`-Datei, wenn du einen Intel-Mac verwendest.

### macOS, mit Homebrew

```
$ brew tap mittwald/cli
$ brew install mittwald-cli
$ mw --help
```

### Windows, mit dem Installationspaket

Lade das neueste Installationspaket (`*.exe`-Datei) von unserer [Releases-Seite](https://github.com/mittwald/cli/releases) herunter und führe den Installer aus.

### Mit Docker

```
$ export MITTWALD_API_TOKEN=xxx
$ docker run \
--rm \
-it \
-e MITTWALD_API_TOKEN \
mittwald/cli --help
```

## Authentifizierung

Um die CLI zu verwenden, musst du dich zunächst mit einem API-Token authentifizieren. Schau dir den Abschnitt ["Ein API-Token beziehen"](../../intro#obtaining-an-api-token) der Einführung an, um Details zum Erhalt eines API-Tokens zu erfahren.

:::note

Weitere Authentifizierungsmechanismen (wie z.B. ein OAuth2-Flow, bei dem du deinen Browser zur Authentifizierung verwenden kannst) sind für die Zukunft geplant.

:::

Mit einem Token kannst du dich wie folgt authentifizieren:

```
$ mw login token
Enter your mStudio API token: ********
```

Für nicht-interaktive Nutzung (beispielsweise in CI/CD-Pipelines), kannst du das Token auch über die `MITTWALD_API_TOKEN`-Umgebungsvariable bereitstellen:

```
$ export MITTWALD_API_TOKEN=********
$ mw login status
```

## Allgemeine Verwendung

### Projekt-, Server- und Organisations-Kontexte

Viele Befehle der CLI agieren im Kontext eines bestimmten Projekts, Servers oder einer Organisation und benötigen daher einen `--project-id`, `--server-id` oder `--org-id`-Parameter. Du kannst diese Parameter entweder an jeden Befehl übergeben, oder sie global mit dem `mw context`-Befehl setzen:

```bash
$ mw context set --project-id=...
$ mw project set --server-id=...
$ mw project set --org-id=...
```

Manche Befehle, die eine dieser Ressourcen erstellen, haben auch ein `--update-context`-Flag, das den Kontext automatisch auf die neu erstellte Ressource setzt:

```bash
$ mw project create --description="..." --update-context
```

### Nicht-interaktive Nutzung

Falls du `mw` auf nicht-interaktive Weise verwenden möchtest (z.B. in Skripten oder CI/CD-Pipelines), unterstützen viele Befehle ein `--output|-o`-Flag, mit dem du das Ausgabeformat angeben kannst. Standardwert ist `text`, was in einer menschenlesbaren Ausgabe resultiert. Du kannst auch `json` verwenden, um maschinenlesbare Ausgaben zu erhalten, die du dann leicht mit Werkzeugen wie `jq` verarbeiten kannst:

```bash
PROJECT_ID=$(mw project get -ojson | jq -r '.id')
```

Viele Befehle, die eine Ressource erstellen, geben standardmäßig Fortschrittsinformationen aus. Sie haben aber auch ein `--quiet|-q`-Flag, mit dem du die Ausgabe unterdrücken kannst. In diesen Fällen geben die meisten Befehle die ID der erstellten Ressource aus, die du dann verwenden kannst, um damit weiterzuarbeiten:

```bash
PROJECT_ID=$(mw project create --quiet --description="...")
```
4 changes: 4 additions & 0 deletions src/components/HomepageFeatures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import clsx from "clsx";
import styles from "./styles.module.css";
import Translate from "@docusaurus/Translate";
import Link from "@docusaurus/Link";
import { NewBadge } from "../NewBadge";

const issueTrackerURL =
"https://github.com/mittwald/developer-portal/issues/new?assignees=&labels=suggestion&projects=&template=suggestion.md";
Expand Down Expand Up @@ -132,6 +133,9 @@ const FeatureList = [
</Translate>
</p>
<ul>
<li>
<Link to="/docs/v2/api/sdks/cli">mittwald CLI</Link> <NewBadge />
</li>
<li>
<Link to="/docs/v2/api/sdks/javascript">
mittwald JavaScript SDK
Expand Down
11 changes: 11 additions & 0 deletions src/components/NewBadge/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import styles from "./styles.module.css";
import clsx from "clsx";

export function NewBadge() {
return (
<div className={clsx("badge", styles.badgeNew)}>
<span>NEW</span>
</div>
);
}
13 changes: 13 additions & 0 deletions src/components/NewBadge/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.badgeNew {
background: radial-gradient(circle at 60.52% 67.2%, #264697, transparent 41%),
radial-gradient(circle at 56.14% 12.23%, #232b69, transparent 85%),
radial-gradient(circle at 6.01% 1.34%, #d989b9, transparent 75%),
radial-gradient(circle at 75.71% 4.03%, #0a0d66, transparent 34%),
radial-gradient(circle at 99.31% 70.7%, #2fd2eb, transparent 75%),
radial-gradient(circle at 76.91% 59.14%, #0a0d66, transparent 71%),
radial-gradient(circle at 71.07% 83.33%, #0a0d66, transparent 71%),
radial-gradient(circle at 15.11% 70.43%, #1556a1, transparent 64%),
radial-gradient(circle at 65.49% 37.9%, #3058a5, transparent 100%),
radial-gradient(circle at 99.4% 93.55%, #12f7ff, transparent 100%),
radial-gradient(circle at 50% 50%, #8f62aa, #8f62aa 100%);
}

0 comments on commit 0851a50

Please sign in to comment.