-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from mittwald/feature/cli
Add section on CLI tool
- Loading branch information
Showing
6 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="...") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
i18n/de/docusaurus-plugin-content-docs/current/api/sdks/cli.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="...") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%); | ||
} |