added doc for how to add a new command group (#575)

Co-authored-by: Joe Zhou <jiazho@microsoft.com>
This commit is contained in:
Jiaxiao Zhou 2020-10-14 19:39:26 -07:00 коммит произвёл GitHub
Родитель 3606c06491
Коммит abab2823bd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -27,6 +27,32 @@
* add **custom.py** file in **manual** folder if it's not exist and provide the implementation for your new command
![sample image](images/manual-override-add-command3.png)
## How to add a new command group
* Add **...\manual\command.py** file if it's not exist and provide your new command group and its commands as below. The client_factory is optional and is needed when you want to use the special arguments such as `cmd`. You can take **...\generated\command.py** as a reference.
```python
def load_command_table(self, _):
from azext_ml.generated._client_factory import cf_ml_cl
with self.command_group('portal newgroup', client_factory=cf_ml_cl) as g:
g.custom_command('create', 'newgroup_create')
g.custom_command('update', 'newgroup_show')
g.custom_command('delete', 'newgroup_delete')
```
* Add **...\manual\custom.py** file if it's not exist and implement your new command. You can take **...\generated\custom.py** as a reference.
```python
def newgroup_create(cmd, arg0, arg1, ...):
...
def newgroup_show(cmd, arg0, arg1, ...):
...
def newgroup_delete(cmd, arg0, arg1, ...):
...
```
* As above, you can add or edit **...\manual\\_params.py** file to implement arguments for your new commands.
* Make sure you can run these commands in the terminal of your choice:
```bash
az portal newgroup create
```
## Overriding Actions
It's also possible to override actions or add any new actions by adding **actions.py** file in **manual** folder.