Skip to content

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

Merged
Hook25 merged 6 commits intomainfrom
list_json
Feb 13, 2025
Merged

Add 'json' as a new special formatter for list (New)#1711
Hook25 merged 6 commits intomainfrom
list_json

Conversation

@Hook25
Copy link
Copy Markdown
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

@codecov
Copy link
Copy Markdown

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 142 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 ∅ <85.00%> (∅)

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Hook25 Hook25 marked this pull request as ready for review February 12, 2025 16:33
Copy link
Copy Markdown
Collaborator

@pieqq pieqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff!

It's going to be really helpful, very soon :D

@Hook25 Hook25 merged commit f3f6f79 into main Feb 13, 2025
48 of 49 checks passed
@Hook25 Hook25 deleted the list_json branch February 13, 2025 08:47
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.

2 participants