Skip to content

Commit

Permalink
Add json output for collections subcommand (#1420)
Browse files Browse the repository at this point in the history
* Add json output for collections subcommand

* Typo

* Restore launch.json
  • Loading branch information
cidrblock authored Jan 23, 2023
1 parent af9c57b commit e09a6c2
Show file tree
Hide file tree
Showing 31 changed files with 742 additions and 99 deletions.
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def run_stdout(self) -> RunStdoutReturn:

print_to_stdout(
content=collections_info,
content_format=ContentFormat.YAML,
content_format=getattr(ContentFormat, self._args.format.upper()),
use_color=self._args.display_color,
)
return RunStdoutReturn(message="", return_code=0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ class Internals:
value=SettingsEntryValue(),
version_added="v1.0",
),
SettingsEntry(
name="format",
choices=["json", "yaml"],
cli_parameters=CliParameters(short="--fmt"),
short_description="Specify the format for stdout output.",
subcommands=["collections"],
value=SettingsEntryValue(default="yaml"),
version_added="v2.3",
),
SettingsEntry(
name="help_builder",
choices=[True, False],
Expand Down
4 changes: 3 additions & 1 deletion src/ansible_navigator/data/settings-sample.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ ansible-navigator:
- src: "/tmp/directory"
dest: "/tmp/directory"
options: "Z"
# {{ inventory-columns }}
# {{ format }}
format: json
images:
# {{ images.details }}
details:
- ansible_collections
- ansible_version
# {{ inventory-columns }}
inventory-columns:
- ansible_network_os
- ansible_network_cli_ssh_type
Expand Down
3 changes: 3 additions & 0 deletions src/ansible_navigator/data/settings-schema.partial.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@
},
"type": "object"
},
"format": {
"type": "string"
},
"images": {
"additionalProperties": false,
"properties": {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"additional_information": {
"present": [
"Ansible runner artifact dir",
"Help playbook"
"Help inventory"
],
"absent": [],
"compared_fixture": false
Expand All @@ -30,11 +30,11 @@
"15│Execution environment True Command line True",
"16│Execution environment image True Defaults ghcr.io/ansible/creator-ee:v0.13.0",
"17│Execution environment volume mounts True Not set Not set",
"18│Help builder True Defaults False",
"19│Help config True Defaults False",
"20│Help doc True Defaults False",
"21│Help inventory True Defaults False",
"22│Help playbook True Defaults False",
"18│Format True Defaults yaml",
"19│Help builder True Defaults False",
"20│Help config True Defaults False",
"21│Help doc True Defaults False",
"22│Help inventory True Defaults False",
"^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :help help"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"additional_information": {
"present": [
"Ansible runner artifact dir",
"Help playbook"
"Help inventory"
],
"absent": [],
"compared_fixture": false
Expand All @@ -30,11 +30,11 @@
"15│Execution environment True Command line True",
"16│Execution environment image True Defaults ghcr.io/ansible/creator-ee:v0.13.0",
"17│Execution environment volume mounts True Not set Not set",
"18│Help builder True Defaults False",
"19│Help config True Defaults False",
"20│Help doc True Defaults False",
"21│Help inventory True Defaults False",
"22│Help playbook True Defaults False",
"18│Format True Defaults yaml",
"19│Help builder True Defaults False",
"20│Help config True Defaults False",
"21│Help doc True Defaults False",
"22│Help inventory True Defaults False",
"^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :help help"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"additional_information": {
"present": [
"Ansible runner artifact dir",
"Help playbook"
"Help inventory"
],
"absent": [],
"compared_fixture": false
Expand All @@ -30,11 +30,11 @@
"15│Execution environment True Command line True",
"16│Execution environment image True Defaults ghcr.io/ansible/creator-ee:v0.13.0",
"17│Execution environment volume mounts True Not set Not set",
"18│Help builder True Defaults False",
"19│Help config True Defaults False",
"20│Help doc True Defaults False",
"21│Help inventory True Defaults False",
"22│Help playbook True Defaults False",
"18│Format True Defaults yaml",
"19│Help builder True Defaults False",
"20│Help config True Defaults False",
"21│Help doc True Defaults False",
"22│Help inventory True Defaults False",
"^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :help help"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"additional_information": {
"present": [
"Ansible runner artifact dir",
"Help playbook"
"Help inventory"
],
"absent": [],
"compared_fixture": false
Expand All @@ -30,11 +30,11 @@
"15│Execution environment False Command line False",
"16│Execution environment image True Defaults ghcr.io/ansible/creator-ee:v0.13.0",
"17│Execution environment volume mounts True Not set Not set",
"18│Help builder True Defaults False",
"19│Help config True Defaults False",
"20│Help doc True Defaults False",
"21│Help inventory True Defaults False",
"22│Help playbook True Defaults False",
"18│Format True Defaults yaml",
"19│Help builder True Defaults False",
"20│Help config True Defaults False",
"21│Help doc True Defaults False",
"22│Help inventory True Defaults False",
"^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :help help"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"additional_information": {
"present": [
"Ansible runner artifact dir",
"Help playbook"
"Help inventory"
],
"absent": [],
"compared_fixture": false
Expand All @@ -30,11 +30,11 @@
"15│Execution environment False Command line False",
"16│Execution environment image True Defaults ghcr.io/ansible/creator-ee:v0.13.0",
"17│Execution environment volume mounts True Not set Not set",
"18│Help builder True Defaults False",
"19│Help config True Defaults False",
"20│Help doc True Defaults False",
"21│Help inventory True Defaults False",
"22│Help playbook True Defaults False",
"18│Format True Defaults yaml",
"19│Help builder True Defaults False",
"20│Help config True Defaults False",
"21│Help doc True Defaults False",
"22│Help inventory True Defaults False",
"^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :help help"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"additional_information": {
"present": [
"Ansible runner artifact dir",
"Help playbook"
"Help inventory"
],
"absent": [],
"compared_fixture": false
Expand All @@ -30,11 +30,11 @@
"15│Execution environment False Command line False",
"16│Execution environment image True Defaults ghcr.io/ansible/creator-ee:v0.13.0",
"17│Execution environment volume mounts True Not set Not set",
"18│Help builder True Defaults False",
"19│Help config True Defaults False",
"20│Help doc True Defaults False",
"21│Help inventory True Defaults False",
"22│Help playbook True Defaults False",
"18│Format True Defaults yaml",
"19│Help builder True Defaults False",
"20│Help config True Defaults False",
"21│Help doc True Defaults False",
"22│Help inventory True Defaults False",
"^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :help help"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
"compared_fixture": false
},
"output": [
" }",
" },",
" \"type\": \"object\"",
" },",
" \"image\": {",
" \"description\": \"Specify the name of the execution environment image\",",
" \"type\": \"string\"",
" },",
" \"pull\": {",
" \"additionalProperties\": false,",
" \"properties\": {",
" \"arguments\": {",
Expand Down Expand Up @@ -68,6 +59,15 @@
" },",
" \"type\": \"object\"",
" },",
" \"format\": {",
" \"default\": \"yaml\",",
" \"description\": \"Specify the format for stdout output.\",",
" \"enum\": [",
" \"json\",",
" \"yaml\"",
" ],",
" \"type\": \"string\"",
" },",
" \"images\": {",
" \"additionalProperties\": false,",
" \"properties\": {",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
"compared_fixture": false
},
"output": [
" }",
" },",
" \"type\": \"object\"",
" },",
" \"image\": {",
" \"description\": \"Specify the name of the execution environment image\",",
" \"type\": \"string\"",
" },",
" \"pull\": {",
" \"additionalProperties\": false,",
" \"properties\": {",
" \"arguments\": {",
Expand Down Expand Up @@ -68,6 +59,15 @@
" },",
" \"type\": \"object\"",
" },",
" \"format\": {",
" \"default\": \"yaml\",",
" \"description\": \"Specify the format for stdout output.\",",
" \"enum\": [",
" \"json\",",
" \"yaml\"",
" ],",
" \"type\": \"string\"",
" },",
" \"images\": {",
" \"additionalProperties\": false,",
" \"properties\": {",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@
"# - src: \"/tmp/directory\"",
"# dest: \"/tmp/directory\"",
"# options: \"Z\"",
"# # Specify a host attribute to show in the inventory view",
"# # Specify the format for stdout output.",
"# format: json",
"# images:",
"# # Provide detailed information about the selected execution environment",
"# # image",
"# details:",
"# - ansible_collections",
"# - ansible_version",
"# # Specify a host attribute to show in the inventory view",
"# inventory-columns:",
"# - ansible_network_os",
"# - ansible_network_cli_ssh_type",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
" image: ghcr.io/ansible/creator-ee:v0.13.0",
" pull:",
" policy: never",
" format: yaml",
" images:",
" details:",
" - everything",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"ansible-navigator.execution-environment.pull.arguments: Not set",
"ansible-navigator.execution-environment.pull.policy: Environment variable",
"ansible-navigator.execution-environment.volume-mounts: Not set",
"ansible-navigator.format: Defaults",
"ansible-navigator.images.details: Defaults",
"ansible-navigator.inventory-columns: Not set",
"ansible-navigator.logging.append: Defaults",
Expand Down
Loading

0 comments on commit e09a6c2

Please sign in to comment.