@@ -13,8 +13,6 @@ pub struct DebugArgs {
1313 pub source_text : Option < String > ,
1414 pub source_file : Option < std:: path:: PathBuf > ,
1515 pub lang : Option < String > ,
16- pub query : bool ,
17- pub source : bool ,
1816 pub symbols : bool ,
1917 pub raw : bool ,
2018 pub cst : bool ,
@@ -45,15 +43,11 @@ pub fn run(args: DebugArgs) {
4543 } )
4644 } ) ;
4745
48- let show_headers = [ args. query , args. source , args. symbols ]
49- . iter ( )
50- . filter ( |& & x| x)
51- . count ( )
52- >= 2 ;
46+ let show_query = has_query_input && !args. symbols ;
47+ let show_source = has_source_input;
48+ let show_headers = ( show_query || args. symbols ) && show_source;
5349
54- if args. query
55- && let Some ( ref q) = query
56- {
50+ if show_query && let Some ( ref q) = query {
5751 if show_headers {
5852 println ! ( "=== QUERY ===" ) ;
5953 }
@@ -83,7 +77,7 @@ pub fn run(args: DebugArgs) {
8377 ) ;
8478 }
8579
86- if args . source {
80+ if show_source {
8781 let resolved_lang = resolve_lang ( & args. lang , & args. source_text , & args. source_file ) ;
8882 let source_code = load_source ( & args. source_text , & args. source_file ) ;
8983 let tree = parse_tree ( & source_code, resolved_lang) ;
@@ -120,20 +114,18 @@ fn load_query(args: &DebugArgs) -> String {
120114}
121115
122116fn validate ( args : & DebugArgs , has_query : bool , has_source : bool ) -> Result < ( ) , & ' static str > {
123- if ( args. query || args. symbols ) && !has_query {
124- return Err ( "--query and --only-symbols require --query-text or --query-file" ) ;
117+ if !has_query && !has_source {
118+ return Err (
119+ "specify at least one input: -q/--query, --query-file, -s/--source-file, or --source" ,
120+ ) ;
125121 }
126122
127- if args. source && !has_source {
128- return Err ( "--source requires --source-text or --source -file" ) ;
123+ if args. symbols && !has_query {
124+ return Err ( "--only-symbols requires -q/--query or --query -file" ) ;
129125 }
130126
131127 if args. source_text . is_some ( ) && args. lang . is_none ( ) {
132- return Err ( "--lang is required when using --source-text" ) ;
133- }
134-
135- if !args. query && !args. source && !args. symbols {
136- return Err ( "specify at least one output: --query, --source, or --only-symbols" ) ;
128+ return Err ( "--lang is required when using --source" ) ;
137129 }
138130
139131 Ok ( ( ) )
0 commit comments