From b6cd6830bec8423338f182dfdff7e58326c900af Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Tue, 9 Mar 2021 09:47:22 +0800 Subject: [PATCH 01/10] update setup --- doc/authoring_command_modules/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index df328accf66..e2e7946971c 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -28,9 +28,9 @@ For example: ``` git clone https://github.com/Azure/azure-cli.git cd azure-cli -virtualenv env +python -m venv env source env/bin/activate -python scripts/dev_setup.py +azdev setup -c ``` After this, you should be able to run the CLI with `az`. From b57f13ea854711509e126419cd1e946e3a8b6042 Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Tue, 9 Mar 2021 10:04:32 +0800 Subject: [PATCH 02/10] refine init --- doc/authoring_command_modules/README.md | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index e2e7946971c..ff1fea38d9a 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -32,24 +32,12 @@ python -m venv env source env/bin/activate azdev setup -c ``` +For more information, see https://github.com/Azure/azure-cli-dev-tools#setting-up-your-development-environment. After this, you should be able to run the CLI with `az`. [Author your command module...](#heading_author_command_mod) -Now, install your command module into the environment with pip in editable mode. -Where `` is the path to the directory containing your `setup.py` file. -``` -pip install -e -``` - -If installation was successful, you should be able to run `pip list` and see your command module. -``` -$ pip list -... -azure-cli-example (0.0.1, /Users/myuser/Repos/azure-cli-example) -... -``` Also, you can run `az` and if your command module contributes any commands, they should appear. If your commands aren't showing with `az`, use `az --debug` to help debug. There could have been an exception @@ -58,9 +46,6 @@ thrown whilst attempting to load your module. Authoring command modules ------ -Currently, all command modules should start with `azure-cli-`. -When the CLI loads, it search for packages installed that start with that prefix. - The `example_module_template` directory gives an example command module with other useful examples. Command modules should have the following structure: @@ -79,6 +64,12 @@ Command modules should have the following structure: `-- HISTORY.rst ``` +You could create these files manually, or [create a module with `azdev cli create`](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4). + +You also could consider using [Code-gen tool](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4) to generate code automatically. + + + **Create an \_\_init__.py for your module** In the \_\_init__ file, you will declare a command loader class that inherits from AzCommandsLoader. You will typically override the following three methods: From 852e6db88b12d2a9d646a2b99c91b0664788fa0f Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Tue, 9 Mar 2021 10:08:07 +0800 Subject: [PATCH 03/10] refine --- doc/authoring_command_modules/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index ff1fea38d9a..ded29606322 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -38,8 +38,7 @@ After this, you should be able to run the CLI with `az`. [Author your command module...](#heading_author_command_mod) - -Also, you can run `az` and if your command module contributes any commands, they should appear. +If your command module contributes any commands, they should appear with `az`. If your commands aren't showing with `az`, use `az --debug` to help debug. There could have been an exception thrown whilst attempting to load your module. From a857a2c43154c33b501c9c446c3ee1ac70e57024 Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Thu, 11 Mar 2021 10:42:08 +0800 Subject: [PATCH 04/10] Update doc/authoring_command_modules/README.md Co-authored-by: Feiyue Yu --- doc/authoring_command_modules/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index ded29606322..fd5e0be8eda 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -67,8 +67,6 @@ You could create these files manually, or [create a module with `azdev cli creat You also could consider using [Code-gen tool](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4) to generate code automatically. - - **Create an \_\_init__.py for your module** In the \_\_init__ file, you will declare a command loader class that inherits from AzCommandsLoader. You will typically override the following three methods: From 46e05faf823324bb7d03b3bc74f5f1fd95135d67 Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Thu, 11 Mar 2021 10:42:14 +0800 Subject: [PATCH 05/10] Update doc/authoring_command_modules/README.md Co-authored-by: Feiyue Yu --- doc/authoring_command_modules/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index fd5e0be8eda..89268364b71 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -65,7 +65,7 @@ Command modules should have the following structure: You could create these files manually, or [create a module with `azdev cli create`](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4). -You also could consider using [Code-gen tool](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4) to generate code automatically. +You could also consider using [Code-gen tool](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4) to generate code automatically. **Create an \_\_init__.py for your module** From e95c8223d611c556f3fbdfb25f7a450bf07952c9 Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Thu, 11 Mar 2021 10:42:21 +0800 Subject: [PATCH 06/10] Update doc/authoring_command_modules/README.md Co-authored-by: Feiyue Yu --- doc/authoring_command_modules/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index 89268364b71..b8516e3ef2a 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -30,7 +30,7 @@ git clone https://github.com/Azure/azure-cli.git cd azure-cli python -m venv env source env/bin/activate -azdev setup -c +azdev setup -c azure-cli -r azure-cli-extensions ``` For more information, see https://github.com/Azure/azure-cli-dev-tools#setting-up-your-development-environment. From 3cbd7e8acfaa32341ded591f3767b5430db637c2 Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Fri, 9 Apr 2021 15:54:29 +0800 Subject: [PATCH 07/10] fix comments --- doc/authoring_command_modules/README.md | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index b8516e3ef2a..1e3b12e0688 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -38,34 +38,17 @@ After this, you should be able to run the CLI with `az`. [Author your command module...](#heading_author_command_mod) -If your command module contributes any commands, they should appear with `az`. +If your command module contributes any commands, they should appear when running `az`. If your commands aren't showing with `az`, use `az --debug` to help debug. There could have been an exception thrown whilst attempting to load your module. Authoring command modules ------ -The `example_module_template` directory gives an example command module with other useful examples. -Command modules should have the following structure: -``` -. -|-- README.rst -|-- azure -| |-- __init__.py -| `-- cli -| |-- __init__.py -| `-- command_modules -| |-- __init__.py -| `-- -| `-- __init__.py -`-- setup.py -`-- HISTORY.rst -``` - -You could create these files manually, or [create a module with `azdev cli create`](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4). - -You could also consider using [Code-gen tool](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4) to generate code automatically. +There are two options to initialize a command module: +1. Use [Code-gen tool](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4) to generate code automatically. +2. [Create a module with `azdev cli create`](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4). **Create an \_\_init__.py for your module** From 97f87e780e6cddbbf8e0a6db2c8abb2d8c193a8c Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Fri, 9 Apr 2021 16:16:00 +0800 Subject: [PATCH 08/10] fix link --- doc/authoring_command_modules/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index 1e3b12e0688..a7bf293f5db 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -47,7 +47,7 @@ thrown whilst attempting to load your module. ------ There are two options to initialize a command module: -1. Use [Code-gen tool](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4) to generate code automatically. +1. Use [Azure CLI Code Generator tool](https://github.com/Azure/autorest.az#how-does-azure-cli-code-generator-work) to generate code automatically. 2. [Create a module with `azdev cli create`](https://azurecliprod.blob.core.windows.net/videos/04%20-%20AzdevCliCreate.mp4). **Create an \_\_init__.py for your module** From cadc64e40ff427a4405de72b4c2606c1c960932c Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Fri, 9 Apr 2021 16:17:17 +0800 Subject: [PATCH 09/10] fix typo --- doc/authoring_command_modules/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index a7bf293f5db..aec18352a98 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -20,7 +20,7 @@ The document provides instructions and guidelines on how to author command modul Set Up ------ -Create you dev environment if you haven't already. This is how to do that. +Create your dev environment if you haven't already. This is how to do that. Clone the repo, enter the repo directory then create your virtual environment. From ee902f9a208db5a181a9a143ab993c81be7cd97a Mon Sep 17 00:00:00 2001 From: Zunli Hu Date: Fri, 9 Apr 2021 16:18:41 +0800 Subject: [PATCH 10/10] fix workflow --- doc/authoring_command_modules/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index aec18352a98..afbf73f935e 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -27,7 +27,7 @@ Clone the repo, enter the repo directory then create your virtual environment. For example: ``` git clone https://github.com/Azure/azure-cli.git -cd azure-cli +git clone https://github.com/Azure/azure-cli-extensions.git python -m venv env source env/bin/activate azdev setup -c azure-cli -r azure-cli-extensions