Azure / Azure/azure-cli-extensions

Multiple/nested alias execution

Open
#239 0 comments 0 reactions 1 assignee Claimed by @jiasli View on GitHub
extension/alias Service Attention
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

### Extension name (the extension in question)
alias

### Description of issue (in as much detail as possible)
Is it possible to allow for nested execution or piped execution?

For example, I created this function to start all VM's in a RG, which I'd like to convert to an alias:
```
azStartRG() {
RG="${1:-$RG}"
az vm start --ids $(
az vm list --query "[].id" -o tsv -g $RG
)
}
```

I can get all of the vm-ids like this:
```
[vm-ids {{rg}}]
command = vm list --query [].id --resource-group {{rg}} -o tsv
```

But I don't know how to do something like this:
```
[start-rg {{rg}}]
command = vm start --ids $(az vm-ids {{rg}})
```

When I try the above alias, I get:
```
Alias Manager: Transforming "start-rg {{rg}}" to "vm start --ids $(az vm-ids {{rg}})", with the following positional arguments: {'rg': 'acs-engine-19'}
Alias Manager: Transformed args to ['vm', 'start', '--ids', '$(az', 'vm-ids', 'acs-engine-19)'] in 5.342ms
```

Any pointers?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.