File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use std:: error:: Error ;
22
33use libpkgx:: pantry_db;
4- use rusqlite:: Connection ;
4+ use rusqlite:: { params , Connection } ;
55
66pub fn query ( args : & Vec < String > , silent : bool , conn : & Connection ) -> Result < ( ) , Box < dyn Error > > {
7- let mut fail = false ;
8- for arg in args {
9- let projects = pantry_db:: which ( arg, conn) ?;
10- if projects. is_empty ( ) && silent {
7+ if args. is_empty ( ) {
8+ let mut stmt = conn. prepare ( "SELECT program FROM provides" ) ?;
9+ let mut rows = stmt. query ( params ! [ ] ) ?;
10+ while let Some ( row) = rows. next ( ) ? {
11+ let program: String = row. get ( 0 ) ?;
12+ println ! ( "{}" , program) ;
13+ }
14+ } else {
15+ let mut fail = false ;
16+ for arg in args {
17+ let projects = pantry_db:: which ( arg, conn) ?;
18+ if projects. is_empty ( ) && silent {
19+ std:: process:: exit ( 1 ) ;
20+ } else if projects. is_empty ( ) {
21+ println ! ( "{} not found" , arg) ;
22+ fail = true ;
23+ } else if !silent {
24+ println ! ( "{}" , projects. join( ", " ) ) ;
25+ }
26+ }
27+ if fail {
1128 std:: process:: exit ( 1 ) ;
12- } else if projects. is_empty ( ) {
13- println ! ( "{} not found" , arg) ;
14- fail = true ;
15- } else if !silent {
16- println ! ( "{}" , projects. join( ", " ) ) ;
1729 }
1830 }
19- if fail {
20- std:: process:: exit ( 1 ) ;
21- }
2231 Ok ( ( ) )
2332}
You can’t perform that action at this time.
0 commit comments