Skip to content

Commit dbdaa8c

Browse files
committed
[docs] Update alias docs
Document that default is the only active context, how to recreate aliases from inactive contexts, the new context status output, and the deprecation of prefer.
1 parent bbdd83d commit dbdaa8c

4 files changed

Lines changed: 36 additions & 14 deletions

File tree

‎docs/how-to-guides/manage-instances/use-instance-command-aliases.md‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,21 @@ multipass alias crazy-cat:pwd pwdcc --no-map-working-directory
2929

3030
> See also: [`prefer`](reference-command-line-interface-prefer)
3131
32-
Contexts are sets of aliases. While one can safely work with one context, named `default`, contexts can be useful in some scenarios; for example, to define aliases with the same name in different instances.
32+
```{caution}
33+
Context switching and the `prefer` command are deprecated. Only the `default` context remains active. Existing non-default contexts are inactive, even if one was selected before upgrading.
34+
```
35+
36+
Contexts are sets of aliases. Multipass keeps existing non-default contexts and their definitions so that you can inspect and recreate aliases, but those aliases cannot run. This applies to both `multipass <alias>` and alias scripts on your `PATH`, including context-qualified names.
37+
38+
To migrate an inactive alias, use `multipass aliases` to find its instance, command, and working-directory setting. For example, recreate an alias `secondary.lscc` that runs `ls` on `cozy-canary` with a unique name:
39+
40+
```{code-block} text
41+
multipass alias cozy-canary:ls ls-secondary
42+
```
43+
44+
The new alias belongs to `default` and can be run with `multipass ls-secondary`. If the original working-directory setting is `default`, include `--no-map-working-directory` when recreating it.
3345

34-
You can switch to using another context with `multipass prefer secondary`. Then, defining an alias in the new context is done in the usual way. The name of the alias can coincide with an already defined one. For example, `multipass alias cozy-canary:ls lscc`.
46+
The inactive definition remains available until you remove it, for example with `multipass unalias secondary.lscc`. `multipass prefer` reports an error and cannot reactivate contexts.
3547

3648
## List the existing aliases
3749

@@ -42,13 +54,13 @@ To see the list of aliases defined so far, use the `multipass aliases` command.
4254
The output will be similar to the following:
4355

4456
```{code-block} text
45-
Alias Instance Command Context Working directory
46-
lscc crazy-cat ls default map
47-
pwdcc crazy-cat pwd default default
48-
lscc cozy-canary ls secondary* map
57+
Alias Instance Command Context Working directory Context status
58+
lscc crazy-cat ls default* map active
59+
pwdcc crazy-cat pwd default* default active
60+
lscc cozy-canary ls secondary map inactive
4961
```
5062

51-
The current context is marked with an asterisk.
63+
The active `default` context is marked with an asterisk. The `Context status` column distinguishes usable aliases in `default` from retained definitions in inactive contexts.
5264

5365
The column `Working directory` tells us on which directory of the host the alias will be run. The value `default` means that the alias will be run in the instance default working directory (normally, `/home/ubuntu`). The value `map` means that, in case the host directory from which the user calls the alias is mounted on the instance, the alias will be run on the mounted directory on the instance. The value will be `default` only if the `--no-map-working-directory` argument is present at alias creation.
5466

@@ -66,9 +78,9 @@ The first way of running an alias is invoking it with `multipass <alias>`, for e
6678
multipass lscc
6779
```
6880

69-
This command opens a shell into the instance `cozy-canary`, runs `ls` and returns to the host command line, as if it was an `exec` command. Since we have defined two aliases with the same name, `lscc`, the one in the current context will be run.
81+
This command opens a shell into the instance `crazy-cat`, runs `ls` and returns to the host command line, as if it was an `exec` command. The alias in `default` runs; the definition with the same name in the inactive `secondary` context cannot run.
7082

71-
If you want to run an alias outside the current context, you can use a fully-qualified alias name:
83+
You can also use the fully-qualified name of an alias in `default`:
7284

7385
```{code-block} text
7486
multipass default.lscc
@@ -209,7 +221,7 @@ The `unalias` command accepts many arguments, specifying more than one alias to
209221
multipass unalias lscc pwdcc
210222
```
211223

212-
You can also use the `--all` option to remove all the defined aliases in the current context at once:
224+
You can also use the `--all` option to remove all the defined aliases at once, including those in inactive contexts:
213225

214226
```{code-block} text
215227
multipass unalias --all

‎docs/reference/command-line-interface/alias.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ multipass alias instance:command [name]
1111

1212
If `name` is omitted, the alias name defaults to `command`.
1313

14-
After running this command, a new alias is defined as running the `command` on the given instance.
14+
After running this command, a new alias is defined in the `default` context as running the `command` on the given instance. Non-default contexts are inactive; use this command with a unique name to recreate an alias from an inactive context.
1515

1616
By default, if the host folder where the alias is being executed is mounted on the instance, the instance's working directory is changed to the mounted directory. This behaviour can be avoided by defining the alias with the option `--no-map-working-directory`.
1717

‎docs/reference/command-line-interface/aliases.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ multipass aliases
1212
The output will be similar to the following:
1313

1414
```{code-block} text
15-
Alias Instance Command Working directory
16-
lsrm rewarded-merlin ls default
17-
topfp flying-pig top map
15+
Alias Instance Command Context Working directory Context status
16+
lsrm rewarded-merlin ls default* default active
17+
topfp flying-pig top default* map active
1818
```
1919

20+
The `default` context is marked with an asterisk and has status `active`; its aliases remain usable. Non-default contexts have status `inactive`. Their definitions remain listed, but their aliases cannot be executed, including through context-qualified names or existing alias scripts.
21+
2022
The `Working directory` column tells us the directory of the host where the alias will be run. The value `default` means that the alias will be run in the instance's default working directory (normally, `/home/ubuntu`). The value `map` means that, if the host directory from which the user calls the alias is mounted on the instance, the alias will be run on the mounted directory on the instance.
2123

2224
```{note}
@@ -25,6 +27,10 @@ The value will be `default` only if the alias was created with the `--no-map-wor
2527

2628
The command can be used in conjunction with the `--format` or `-f` options to specify the desired output format: `csv`, `json`, `table` or `yaml`.
2729

30+
CSV output also includes a `Context status` column. JSON and YAML output include a mapping from context names to `active` or `inactive` in `context-status` and `context_status`, respectively. Existing definitions are preserved; the active context is always `default`.
31+
32+
To use an inactive alias, recreate its instance and command definition with `multipass alias <instance>:<command> <new-name>`. New aliases are created in `default`. Preserve `--no-map-working-directory` when recreating an alias whose working directory is `default`.
33+
2834
```{note}
2935
The `json`, `csv` and `yaml` formats cover regular output only. Errors and log messages are printed to the standard error stream as plain text, with failures signaled by a non-zero exit status.
3036
```

‎docs/reference/command-line-interface/prefer.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ The `prefer` command is deprecated and will be removed in an upcoming release. U
99

1010
The `prefer` command previously switched alias contexts. It remains recognised during the deprecation period, but returns an error instead of creating or switching contexts.
1111

12+
Only the `default` context is active. Its aliases continue to work. Existing non-default contexts are inactive: their definitions remain visible in [`aliases`](/reference/command-line-interface/aliases), but cannot be executed, even using a context-qualified name.
13+
14+
To use a definition from an inactive context, recreate it in `default` with [`alias`](/reference/command-line-interface/alias), choosing a unique name. See [Use instance command aliases](/how-to-guides/manage-instances/use-instance-command-aliases) for the migration steps.
15+
1216
---
1317

1418
The full `multipass help prefer` output explains the available options:

0 commit comments

Comments
 (0)