File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ d=" $( cd " $( dirname " $0 " ) /.." && pwd) "
4+ exec " $d " /libexec/search.ts " $@ "
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env -S tea -E deno run --allow-env --allow-read --allow-net
2+
3+ import { parseFlags } from "cliffy/flags/mod.ts"
4+ import { usePantry , useInventory , useFlags } from "hooks"
5+ import * as semver from "semver"
6+
7+ useFlags ( )
8+
9+ const { unknown : [ query ] } = parseFlags ( Deno . args )
10+ const pantry = usePantry ( )
11+
12+ const encoder = new TextEncoder ( )
13+ const print = ( x : string ) => Deno . stdout . write ( encoder . encode ( x ) )
14+
15+ for await ( const pkg of pantry . ls ( ) ) {
16+ let output = false
17+ const bins : string [ ] = [ ]
18+ for ( const bin of await pantry . getProvides ( pkg ) ) {
19+ if ( bin . startsWith ( query ) ) {
20+ output = true
21+ bins . push ( bin )
22+ }
23+ }
24+ if ( output ) {
25+ print ( `${ pkg . project } : ${ bins . join ( ', ' ) } ` )
26+ } else if ( pkg . project . startsWith ( query ) ) {
27+ print ( pkg . project . trim ( ) )
28+ output = true
29+ }
30+ if ( output ) {
31+ const rq = { project : pkg . project , constraint : new semver . Range ( '*' ) }
32+ const got = await useInventory ( ) . select ( rq )
33+ print ( `: ${ got } \n` )
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments