Skip to content

Commit d8d6e56

Browse files
author
serverpod_cloud
committed
feat(scloud): 4fb3a734755a4a5d7f110465df1fee2507c4ceaa
1 parent 6bd5a39 commit d8d6e56

5 files changed

Lines changed: 1246 additions & 24 deletions

File tree

serverpod_cloud_cli/README.md

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,52 @@
1-
![Serverpod banner](https://github.com/serverpod/serverpod/raw/main/misc/images/github-header.webp)
1+
[![Serverpod banner](https://github.com/serverpod/serverpod/raw/main/misc/images/github-header.webp)](https://github.com/serverpod/serverpod)
22

33
# Serverpod Cloud CLI
44

5-
`scloud`, the Serverpod Cloud command, is your command line interface for the Serverpod Cloud platform.
6-
It is used to manage, deploy, and monitor Serverpod Cloud projects.
7-
8-
## Commands
9-
10-
The Serverpod Cloud CLI has the following commands:
11-
12-
| Command | Description |
13-
|---------|-------------|
14-
| version | Print the version of the Serverpod Cloud CLI. |
15-
| auth | Log in, log out, or create an account in Serverpod Cloud. |
16-
| project | Manage Serverpod Cloud projects. |
17-
| user | Manage Serverpod Cloud users. |
18-
| db | Manage Serverpod Cloud DBs. |
19-
| deploy | Deploy a Serverpod project to the cloud. |
20-
| domain | Manage Serverpod Cloud custom domains. |
21-
| env | Manage Serverpod Cloud environment variables for a project. |
22-
| launch | Guided launch of a new Serverpod Cloud project. |
23-
| secret | Manage Serverpod Cloud secrets. |
24-
| log | Fetch Serverpod Cloud logs. |
25-
| status | Show status information. |
5+
The Serverpod Cloud CLI provides all you need to create, manage, and deploy your
6+
Serverpod projects in Serverpod Cloud.
7+
8+
> If you're new to developing with Serverpod, check out the [create a Serverpod project guide](https://docs.serverpod.dev/get-started) in the Serverpod framework docs!
9+
10+
11+
## Getting Started
12+
13+
Run the following to install the CLI:
14+
15+
```sh
16+
dart pub global activate serverpod_cloud_cli
17+
```
18+
19+
Log in to your Serverpod Cloud account using the CLI:
20+
<br/>(If you don't have a Serverpod Cloud account yet, visit [Serverpod Cloud](https://serverpod.cloud/).)
21+
22+
```sh
23+
scloud auth login
24+
```
25+
26+
Go to your Serverpod server directory (e.g. `./myproject/myproject_server`)
27+
and run the [`launch` command](https://docs.serverpod.cloud/references/cli/commands/launch)
28+
to get an interactive, guided set up of a new Serverpod Cloud project:
29+
30+
```sh
31+
scloud launch
32+
```
33+
34+
If the project requires any environment variables or secrets, they can be added with the [`env`](https://docs.serverpod.cloud/references/cli/commands/env) and [`secret`](https://docs.serverpod.cloud/references/cli/commands/secret) commands. Once the project is ready to be deployed, run the following command:
35+
36+
```sh
37+
scloud deploy
38+
```
39+
40+
To follow the progress of the deployment, use the [`status deploy` command](https://docs.serverpod.cloud/references/cli/commands/status):
41+
42+
```sh
43+
scloud status deploy
44+
```
45+
46+
That's it, you have now deployed your Serverpod app! 🚀
47+
48+
For more information on the different commands, see the commands section in the side menu. For instance, to view the service's domains or to add your own custom domains, see the [`domain` command](https://docs.serverpod.cloud/references/cli/commands/domain).
49+
2650

2751
## Online documentation
2852

serverpod_cloud_cli/lib/command_runner/cloud_cli_command_runner.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import 'package:serverpod_cloud_cli/util/scloud_config/scloud_config.dart';
3030
import 'package:serverpod_cloud_cli/util/scloud_version.dart';
3131

3232
import 'commands/admin/admin_command.dart';
33+
import 'completion/completion_script_carapace.dart';
34+
import 'completion/completion_script_completely.dart';
3335

3436
/// Represents the Serverpod Cloud CLI main command, its global options, and subcommands.
3537
class CloudCliCommandRunner extends BetterCommandRunner<GlobalOption, void> {
@@ -76,6 +78,11 @@ class CloudCliCommandRunner extends BetterCommandRunner<GlobalOption, void> {
7678
messageOutput: MessageOutput(
7779
usageLogger: logger.info,
7880
),
81+
enableCompletionCommand: true,
82+
embeddedCompletions: [
83+
completionScriptCompletely,
84+
completionScriptCarapace,
85+
],
7986
);
8087

8188
static CloudCliCommandRunner create({
Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
/// This file is auto-generated.
2+
library;
3+
4+
import 'package:cli_tools/better_command_runner.dart' show CompletionTarget;
5+
6+
const String _completionScript = r'''
7+
# yaml-language-server: $schema=https://carapace.sh/schemas/command.json
8+
name: scloud
9+
persistentFlags:
10+
-q, --quiet: "Suppress all cli output. Is overridden by -v, --verbose."
11+
-v, --verbose: "Prints additional information useful for development. Overrides --q, --quiet."
12+
-a, --analytics: "Toggles if analytics data is sent. "
13+
--no-analytics: "Toggles if analytics data is sent. "
14+
--version: "Prints the version of the Serverpod Cloud CLI."
15+
--scloud-dir=: "Override the directory path where Serverpod Cloud cache/authentication files are stored."
16+
-d, --project-dir=: "The path to the Serverpod Cloud project server directory."
17+
--project-config-file=: "The path to the Serverpod Cloud project configuration file."
18+
--project-config-content=: "Override the scloud project configuration with a YAML string."
19+
--connection-timeout=: "The timeout for the connection to the Serverpod Cloud API."
20+
exclusiveFlags:
21+
- [analytics, no-analytics]
22+
completion:
23+
flag:
24+
scloud-dir: ["$directories"]
25+
project-dir: ["$directories"]
26+
project-config-file: ["$files"]
27+
28+
commands:
29+
- name: completion
30+
31+
commands:
32+
- name: generate
33+
flags:
34+
-t, --target=!: "The target tool format"
35+
-e, --exec-name=: "Override the name of the executable"
36+
-f, --file=: "Write the specification to a file instead of stdout"
37+
completion:
38+
flag:
39+
target: ["completely", "carapace"]
40+
file: ["$files"]
41+
42+
- name: install
43+
flags:
44+
-t, --target=!: "The target tool format"
45+
-e, --exec-name=: "Override the name of the executable"
46+
-d, --write-dir=: "Override the directory to write the script to"
47+
completion:
48+
flag:
49+
target: ["completely", "carapace"]
50+
write-dir: ["$directories"]
51+
52+
- name: version
53+
54+
- name: auth
55+
56+
commands:
57+
- name: login
58+
flags:
59+
-t, --timeout=: "The time to wait for the authentication to complete."
60+
--persistent: "Store the authentication credentials."
61+
--no-persistent: "Store the authentication credentials."
62+
--browser: "Allow CLI to open browser for logging in."
63+
--no-browser: "Allow CLI to open browser for logging in."
64+
exclusiveFlags:
65+
- [persistent, no-persistent]
66+
- [browser, no-browser]
67+
68+
- name: logout
69+
70+
- name: project
71+
72+
commands:
73+
- name: create
74+
flags:
75+
-p, --project=!: "The ID of the project. Can be passed as the first argument."
76+
--enable-db: "Flag to enable the database for the project."
77+
--no-enable-db: "Flag to enable the database for the project."
78+
exclusiveFlags:
79+
- [enable-db, no-enable-db]
80+
81+
- name: delete
82+
flags:
83+
-p, --project=!: "The ID of the project. Can be passed as the first argument."
84+
85+
- name: list
86+
flags:
87+
--all: "Include deleted projects."
88+
89+
- name: link
90+
flags:
91+
-p, --project=!: "The ID of the project. Can be passed as the first argument."
92+
93+
- name: invite
94+
flags:
95+
-p, --project=!: "The ID of the project. Can be passed as the first argument.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
96+
-u, --user=!: "The user email address."
97+
-r, --role=*!: "One or more project roles to assign."
98+
completion:
99+
flag:
100+
role: ["admin"]
101+
102+
- name: revoke
103+
flags:
104+
-p, --project=!: "The ID of the project. Can be passed as the first argument.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
105+
-u, --user=!: "The user email address. Can be passed as the second argument."
106+
-r, --role=*: "One or more project roles to revoke."
107+
--all: "Revoke all roles of this project from the user."
108+
completion:
109+
flag:
110+
role: ["admin"]
111+
112+
- name: deploy
113+
flags:
114+
-p, --project=!: "The ID of the project. Can be passed as the first argument.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
115+
-c, --concurrency=: "Number of concurrent files processed when zipping the project."
116+
--dry-run: "Do not actually deploy, just print the deployment steps."
117+
--no-dry-run: "Do not actually deploy, just print the deployment steps."
118+
exclusiveFlags:
119+
- [dry-run, no-dry-run]
120+
121+
- name: env
122+
123+
commands:
124+
- name: create
125+
flags:
126+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
127+
--name=!: "The name of the environment variable. Can be passed as the first argument."
128+
--value=: "The value of the environment variable. Can be passed as the second argument."
129+
--from-file=: "The name of the file with the environment variable value."
130+
completion:
131+
flag:
132+
from-file: ["$files"]
133+
134+
- name: list
135+
flags:
136+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
137+
138+
- name: update
139+
flags:
140+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
141+
--name=!: "The name of the environment variable. Can be passed as the first argument."
142+
--value=: "The value of the environment variable. Can be passed as the second argument."
143+
--from-file=: "The name of the file with the environment variable value."
144+
completion:
145+
flag:
146+
from-file: ["$files"]
147+
148+
- name: delete
149+
flags:
150+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
151+
--name=!: "The name of the environment variable. Can be passed as the first argument."
152+
153+
- name: domain
154+
155+
commands:
156+
- name: add
157+
flags:
158+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
159+
--name=!: "The custom domain name. Can be passed as the first argument."
160+
-t, --target=!: "The Serverpod server target of the custom domain, only one can be specified."
161+
completion:
162+
flag:
163+
target: ["api", "insights", "web"]
164+
165+
- name: list
166+
flags:
167+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
168+
169+
- name: remove
170+
flags:
171+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
172+
--name=!: "The custom domain name. Can be passed as the first argument."
173+
174+
- name: verify
175+
flags:
176+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
177+
--name=!: "The custom domain name. Can be passed as the first argument."
178+
179+
- name: log
180+
flags:
181+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
182+
--limit=: "The maximum number of log records to fetch."
183+
-u, --utc: "Display timestamps in UTC timezone instead of local."
184+
--no-utc: "Display timestamps in UTC timezone instead of local."
185+
-r, --recent=: "Fetch records from the recent period length; s (seconds) by default. Can also be specified as the first argument."
186+
--before=: "Fetch records from before this timestamp."
187+
--after=: "Fetch records from after this timestamp."
188+
--tail: "Tail the log and get real time updates."
189+
exclusiveFlags:
190+
- [utc, no-utc]
191+
192+
- name: status
193+
194+
commands:
195+
- name: deploy
196+
flags:
197+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
198+
--limit=: "The maximum number of records to fetch."
199+
-u, --utc: "Display timestamps in UTC timezone instead of local."
200+
--no-utc: "Display timestamps in UTC timezone instead of local."
201+
--deploy=: "View a specific deployment, with uuid or sequence number, 0 for latest. Can be passed as the first argument."
202+
-l, --list: "List recent deployments."
203+
-b, --build-log: "View a deployment's build log, or latest by default."
204+
--output-overall-status: "View a deployment's overall status as a single word, one of: success, failure, awaiting, running, cancelled, unknown."
205+
exclusiveFlags:
206+
- [utc, no-utc]
207+
208+
- name: secret
209+
210+
commands:
211+
- name: create
212+
flags:
213+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
214+
--name=!: "The name of the secret. Can be passed as the first argument."
215+
--value=: "The value of the secret. Can be passed as the second argument."
216+
--from-file=: "The name of the file with the secret value."
217+
completion:
218+
flag:
219+
from-file: ["$files"]
220+
221+
- name: list
222+
flags:
223+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
224+
225+
- name: delete
226+
flags:
227+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
228+
--name=!: "The name of the secret. Can be passed as the first argument."
229+
230+
- name: db
231+
232+
commands:
233+
- name: connection
234+
flags:
235+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
236+
237+
- name: create-superuser
238+
flags:
239+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
240+
--username=!: "The username of the DB user to create."
241+
242+
- name: reset-password
243+
flags:
244+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
245+
--username=!: "The username of the DB user to create."
246+
247+
- name: launch
248+
flags:
249+
-p, --project=: "The ID of the project."
250+
--enable-db: "Flag to enable the database for the project."
251+
--no-enable-db: "Flag to enable the database for the project."
252+
--deploy: "Flag to immediately deploy the project."
253+
--no-deploy: "Flag to immediately deploy the project."
254+
exclusiveFlags:
255+
- [enable-db, no-enable-db]
256+
- [deploy, no-deploy]
257+
258+
- name: user
259+
260+
commands:
261+
- name: list
262+
flags:
263+
-p, --project=!: "The ID of the project.\nCan be omitted for existing projects that are linked. See `scloud project link --help`."
264+
265+
266+
''';
267+
268+
/// Embedded script for command line completion for `carapace`.
269+
const completionScriptCarapace = (
270+
target: CompletionTarget.carapace,
271+
script: _completionScript,
272+
);

0 commit comments

Comments
 (0)