Skip to content

Commit f6d37b6

Browse files
[UX]: Better UX for switching between projects using the CLI #2553
1 parent 406d949 commit f6d37b6

5 files changed

Lines changed: 73 additions & 7 deletions

File tree

docs/docs/concepts/projects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ and when using the CLI or API.
4949

5050
### Setting up the CLI
5151

52-
To use the CLI with a specific project, run the `dstack config` command with the server address, user token, and project name.
52+
You can configure multiple projects on the client and set the default project using the [`dstack project`](../reference/cli/dstack/project.md) CLI command.
5353

5454
You can find the command on the project’s settings page:
5555

56-
<img src="https://dstack.ai/static-assets/static-assets/images/dstack-projects-project-cli.png" width="750px" />
56+
<img src="https://dstack.ai/static-assets/static-assets/images/dstack-projects-project-cli-v2.png" width="750px" />
5757

5858
??? info "API"
5959
In addition to the UI, managing projects, users, and user permissions can also be done via the [REST API](../reference/api/rest/index.md).

docs/docs/reference/cli/dstack/config.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# dstack config
22

3+
!!! info "Deprecated"
4+
The `dstack config` is deprecated. Use [`dstack project`](project.md) instead.
5+
36
Both the CLI and API need to be configured with the server address, user token, and project name
47
via `~/.dstack/config.yml`.
58

@@ -13,7 +16,7 @@ To use CLI and API on different machines or projects, use the `dstack config` co
1316
<div class="termy">
1417

1518
```shell
16-
$ dstack project --help
19+
$ dstack config --help
1720
#GENERATE#
1821
```
1922

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# dstack project
2+
3+
Before the CLI can be used, it must be configured with a [project](../../../concepts/projects.md), including a project name, server address, and user token. You can configure multiple projects using the `dstack project` CLI command. The configuration is stored in `~/.dstack/config.yml`.
4+
5+
> The `dstack server` command automatically creates the default `main` project and adds its configuration in `~/.dstack/config.yml`.
6+
7+
The `dstack project set-default` command can be used to switch between multiple projects.
8+
9+
## dstack project add
10+
11+
This command adds a new project configuration.
12+
13+
<div class="termy">
14+
15+
```shell
16+
$ dstack project add --help
17+
#GENERATE#
18+
```
19+
20+
</div>
21+
22+
You can find the command on the project’s settings page:
23+
24+
<img src="https://dstack.ai/static-assets/static-assets/images/dstack-projects-project-cli-v2.png" width="750px" />
25+
26+
## dstack project list
27+
28+
This command lists the projects configured on the client.
29+
30+
<div class="termy">
31+
32+
```shell
33+
$ dstack project list --help
34+
#GENERATE#
35+
```
36+
37+
</div>
38+
39+
## dstack project set-default
40+
41+
This command sets the given project as default.
42+
43+
<div class="termy">
44+
45+
```shell
46+
$ dstack project set-default --help
47+
#GENERATE#
48+
```
49+
50+
</div>
51+
52+
## dstack project delete
53+
54+
This command deletes the given project configuration.
55+
56+
<div class="termy">
57+
58+
```shell
59+
$ dstack project delete --help
60+
#GENERATE#
61+
```
62+
63+
</div>

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ nav:
245245
- dstack attach: docs/reference/cli/dstack/attach.md
246246
- dstack logs: docs/reference/cli/dstack/logs.md
247247
- dstack metrics: docs/reference/cli/dstack/metrics.md
248-
- dstack config: docs/reference/cli/dstack/config.md
248+
- dstack project: docs/reference/cli/dstack/project.md
249249
- dstack fleet: docs/reference/cli/dstack/fleet.md
250250
- dstack offer: docs/reference/cli/dstack/offer.md
251251
- dstack volume: docs/reference/cli/dstack/volume.md

src/dstack/_internal/cli/commands/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515

1616
class ProjectCommand(BaseCommand):
1717
NAME = "project"
18-
DESCRIPTION = "Manage projects"
18+
DESCRIPTION = "Manage projects configs"
1919

2020
def _register(self):
2121
super()._register()
2222
subparsers = self._parser.add_subparsers(dest="subcommand", help="Command to execute")
2323

2424
# Add subcommand
25-
add_parser = subparsers.add_parser("add", help="Add or update a project")
25+
add_parser = subparsers.add_parser("add", help="Add or update a project config")
2626
add_parser.add_argument(
2727
"--name", type=str, help="The name of the project to configure", required=True
2828
)
@@ -43,7 +43,7 @@ def _register(self):
4343
add_parser.set_defaults(subfunc=self._add)
4444

4545
# Delete subcommand
46-
delete_parser = subparsers.add_parser("delete", help="Delete a project")
46+
delete_parser = subparsers.add_parser("delete", help="Delete a project config")
4747
delete_parser.add_argument(
4848
"--name", type=str, help="The name of the project to delete", required=True
4949
)

0 commit comments

Comments
 (0)