Skip to content
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

Add 'json' as a new special formatter for list (New) #1711

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

Hook25
Copy link
Collaborator

@Hook25 Hook25 commented Feb 6, 2025

Description

Often we want list to expose some data that then we query and modify via grep/sed, this is not a great way to go about it and we would prefer using jq (especially because --format is hard to use effectively). This adds the possibility to do it.

Resolved issues

N/A

Documentation

Help string was updated

Tests

The addition (and the printer itself) was updated.

To test this run: (this will list all jobs)

checkbox-cli list 'job' --format=json --attrs | jq 

To test this run: (this will list all manifests)

checkbox-cli list 'manifest entry' --format=json --attrs | jq 

Small additional proof of this working:

  • all jobs
(venv)  checkbox-ng (list_json) >  checkbox-cli list all-jobs | grep "id: " | wc -l 
1462
(venv)  checkbox-ng (list_json) >  checkbox-cli list all-jobs -f json --attrs | jq ".[] | .id"   | wc -l
1462
  • jobs
(venv)  checkbox-ng (list_json) >  checkbox-cli list job  | wc -l
1119
(venv)  checkbox-ng (list_json) >  checkbox-cli list job -f json --attrs | jq ".[] | .id"   | wc -l
1119

template:

(venv)  checkbox-ng (list_json) >  checkbox-cli list template -f json --attrs | jq ".[] | .id"   | wc -l
343
(venv)  checkbox-ng (list_json) >  checkbox-cli list template  | wc -l
Skipped file: /home/h25/prj/canonical/checkbox/metabox/metabox/metabox-provider/units/some.yaml
343

manifest entry

(venv)  checkbox-ng (list_json) >  checkbox-cli list "manifest entry" -f json --attrs | jq ".[] | .id"   | wc -l
98
(venv)  checkbox-ng (list_json) >  checkbox-cli list "manifest entry"  | wc -l
98

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 49.17%. Comparing base (bf5da28) to head (c769030).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
checkbox-ng/checkbox_ng/launcher/subcommands.py 85.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1711      +/-   ##
==========================================
+ Coverage   49.12%   49.17%   +0.04%     
==========================================
  Files         372      372              
  Lines       40338    40353      +15     
  Branches     6809     6813       +4     
==========================================
+ Hits        19816    19843      +27     
+ Misses      19799    19784      -15     
- Partials      723      726       +3     
Flag Coverage Δ
checkbox-ng 69.81% <85.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Hook25 Hook25 marked this pull request as ready for review February 12, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant