-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{doc} Refine authoring commands doc #17236
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b6cd683
update setup
Juliehzl b57f13e
refine init
Juliehzl 852e6db
refine
Juliehzl a857a2c
Update doc/authoring_command_modules/README.md
Juliehzl 46e05fa
Update doc/authoring_command_modules/README.md
Juliehzl e95c822
Update doc/authoring_command_modules/README.md
Juliehzl 3cbd7e8
fix comments
Juliehzl 97f87e7
fix link
Juliehzl cadc64e
fix typo
Juliehzl ee902f9
fix workflow
Juliehzl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refine init
- Loading branch information
commit b57f13ea854711509e126419cd1e946e3a8b6042
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,24 +32,12 @@ python -m venv env | |
source env/bin/activate | ||
azdev setup -c | ||
Juliehzl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
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 `<path_to_your_command_module>` is the path to the directory containing your `setup.py` file. | ||
``` | ||
pip install -e <path_to_your_command_module> | ||
``` | ||
|
||
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. | |
|
||
<a name="heading_author_command_mod"></a>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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
|
||
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. | ||
Juliehzl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
|
||
Juliehzl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
**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: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You assume it is Linux environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It is a simple example and for more information about setting up environment, link to https://github.com/Azure/azure-cli-dev-tools#setting-up-your-development-environment for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a hint "This is script for Linux"?