Skip to content

Commit ac326c0

Browse files
authored
Feature: Add heavy macro (#345)
1 parent ce66ab5 commit ac326c0

4 files changed

Lines changed: 25 additions & 17 deletions

File tree

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# qp - query packages
22

3-
`qp` is a command-line program for linux and macOS to query installed packages from any ecosystem.
3+
`qp` is a command-line program for linux and macOS to query installed packages across ecosystems.
44

55
you can find installation instructions [here](#installation).
66

@@ -52,7 +52,7 @@ this package is compatible with the following platforms and distributions:
5252

5353
`qp` supports embedded linux systems, including meta-distributions like [yocto](https://www.yoctoproject.org/) that use `opkg` (`.ipk` packages) or `apt`/`dpkg` (`.deb` packages). `rpm` support is currently on the way!
5454

55-
more distros and non-linux platforms are planned!
55+
more distros and non-unix platforms are planned!
5656

5757
## features
5858

@@ -405,29 +405,17 @@ qp w provides=libssl@3 # packages that provide libssl at depth 3
405405
- `@2`: second-level relations (relations of relations)
406406
- `@3`, `@4`, etc.: deeper levels in the dependency tree
407407

408-
**special behavior for optional dependencies:**
408+
**spefor optional dependencies:**
409409
- `optdepends` and `optional-for` return the optional relationships at the depth 1
410-
- after depth 1, the dependency resolution includes hard dependencies from those optional packages in the final results. this is intentional.
410+
- after epth 1, the dependency resolution includes hard dependencies from those optional packages in the final results. this is intentional.
411411

412412
**examples:**
413413
```bash
414414
# show packages with direct dependencies on python (depth 1 implied)
415415
qp w depends=python
416416

417-
# show packages with direct dependencies on python (explicit depth 1)
418-
qp w depends=python@1
419-
420417
# show packages that indirectly depend on openssl at depth 2
421418
qp w depends=openssl@2
422-
423-
# show direct optional dependencies of vlc
424-
qp w optdepends=vlc@1
425-
426-
# show optional dependencies of vlc at depth 2
427-
qp w optdepends=vlc@2
428-
429-
# show packages that directly optionally depend on ffmpeg
430-
qp w optional-for=ffmpeg@1
431419
```
432420

433421
**note:** depth querying works with all relation fields: `depends`, `optdepends`, `required-by`, `optional-for`, `provides`, `conflicts`, and `replaces`.
@@ -456,11 +444,21 @@ some frequently-used query patterns are available as built-in macros for conveni
456444
qp where no:required-by and reason=dependency and no:optional-for
457445
```
458446

447+
* `heavy` - matches packages 100MB and larger
448+
```
449+
qp w superorphan
450+
```
451+
452+
is equivalent to:
453+
```
454+
qp where size=100MB:
455+
```
456+
459457
these macros can be combined with other queries as usual:
460458

461459
```
462460
qp w orphan and size=100KB:
463-
qp w superorphan and not name=gtk
461+
qp w not superorphan and not name=gtk
464462
```
465463

466464
#### query examples

internal/config/help.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Short Command Examples:
9292
Built-in Macros:
9393
- 'qp w orphan' is equivalent to 'qp where no:required-by and reason=dependency'
9494
- 'qp w superorphan' is equivalent to 'qp where no:required-by and reason=dependency and no:optional-for'
95+
- 'qp w heavy' is equivalent to 'qp where size=100MB:'
9596
9697
Tips:
9798
- Queries can include comma-separated values, these act a shorthand for 'or' logic:

internal/preprocess/macro_engine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func expandWhereMacro(token string) ([]string, bool) {
4848
expanded = []string{"no:required-by", "and", "reason=dependency"}
4949
case "superorphan":
5050
expanded = []string{"no:required-by", "and", "reason=dependency", "and", "no:optional-for"}
51+
case "heavy":
52+
expanded = []string{"size=100MB:"}
5153
default:
5254
return nil, false
5355
}

qp.1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ Matches super-orphaned packages - installed as dependencies but are required by
160160
"qp where superorphan" is equivalent to:
161161
.BR "qp where no:required-by and reason=dependency and no:optional-for"
162162

163+
.TP
164+
.B heavy
165+
Matches heavy packages - 100MB and larger.
166+
167+
"qp where heavy" is equivalent to:
168+
.BR "qp where size=100MB:"
169+
163170
.SH SUPPORTED PACKAGE ECOSYSTEMS
164171
.B qp
165172
automatically detects and queries packages from:

0 commit comments

Comments
 (0)