@@ -10,9 +10,8 @@ use rust_i18n::{i18n, t};
1010use std:: io;
1111use sysinfo:: { Process , RefreshKind , System , get_current_pid, ProcessRefreshKind } ;
1212use tracing:: { error, info, warn, debug} ;
13- use util:: exit;
1413
15- use crate :: util:: { EXIT_INVALID_INPUT , get_input} ;
14+ use crate :: util:: { enable_tracing , exit , EXIT_INVALID_INPUT , EXIT_INVALID_ARGS , get_input, get_schema , merge_parameters , write_object } ;
1615
1716#[ cfg( debug_assertions) ]
1817use crossterm:: event;
@@ -42,7 +41,7 @@ fn main() {
4241
4342 let args = Args :: parse ( ) ;
4443
45- util :: enable_tracing ( args. trace_level . as_ref ( ) , args. trace_format . as_ref ( ) ) ;
44+ enable_tracing ( args. trace_level . as_ref ( ) , args. trace_format . as_ref ( ) ) ;
4645
4746 debug ! ( "{}: {}" , t!( "main.usingDscVersion" ) , env!( "CARGO_PKG_VERSION" ) ) ;
4847
@@ -65,7 +64,7 @@ fn main() {
6564 let merged_parameters = match ( file_params, parameters) {
6665 ( Some ( file_content) , Some ( inline_content) ) => {
6766 info ! ( "{}" , t!( "main.mergingParameters" ) ) ;
68- match util :: merge_parameters ( & file_content, & inline_content) {
67+ match merge_parameters ( & file_content, & inline_content) {
6968 Ok ( merged) => Some ( merged) ,
7069 Err ( err) => {
7170 error ! ( "{}: {err}" , t!( "main.failedMergingParameters" ) ) ;
@@ -89,27 +88,27 @@ fn main() {
8988 SubCommand :: Mcp => {
9089 if let Err ( err) = start_mcp_server ( ) {
9190 error ! ( "{}" , t!( "main.failedToStartMcpServer" , error = err) ) ;
92- exit ( util :: EXIT_MCP_FAILED ) ;
91+ exit ( EXIT_MCP_FAILED ) ;
9392 }
94- exit ( util :: EXIT_SUCCESS ) ;
93+ exit ( EXIT_SUCCESS ) ;
9594 }
9695 SubCommand :: Resource { subcommand } => {
9796 subcommand:: resource ( & subcommand, progress_format) ;
9897 } ,
9998 SubCommand :: Schema { dsc_type , output_format } => {
100- let schema = util :: get_schema ( dsc_type) ;
99+ let schema = get_schema ( dsc_type) ;
101100 let json = match serde_json:: to_string ( & schema) {
102101 Ok ( json) => json,
103102 Err ( err) => {
104103 error ! ( "JSON: {err}" ) ;
105- exit ( util :: EXIT_JSON_ERROR ) ;
104+ exit ( EXIT_JSON_ERROR ) ;
106105 }
107106 } ;
108- util :: write_object ( & json, output_format. as_ref ( ) , false ) ;
107+ write_object ( & json, output_format. as_ref ( ) , false ) ;
109108 } ,
110109 }
111110
112- exit ( util :: EXIT_SUCCESS ) ;
111+ exit ( EXIT_SUCCESS ) ;
113112}
114113
115114fn ctrlc_handler ( ) {
@@ -120,16 +119,16 @@ fn ctrlc_handler() {
120119 info ! ( "{}: {}" , t!( "main.foundProcesses" ) , sys. processes( ) . len( ) ) ;
121120 let Ok ( current_pid) = get_current_pid ( ) else {
122121 error ! ( "{}" , t!( "main.failedToGetPid" ) ) ;
123- exit ( util :: EXIT_CTRL_C ) ;
122+ exit ( EXIT_CTRL_C ) ;
124123 } ;
125124 info ! ( "{}: {}" , t!( "main.currentPid" ) , current_pid) ;
126125 let Some ( current_process) = sys. process ( current_pid) else {
127126 error ! ( "{}" , t!( "main.failedToGetProcess" ) ) ;
128- exit ( util :: EXIT_CTRL_C ) ;
127+ exit ( EXIT_CTRL_C ) ;
129128 } ;
130129
131130 terminate_subprocesses ( & sys, current_process) ;
132- exit ( util :: EXIT_CTRL_C ) ;
131+ exit ( EXIT_CTRL_C ) ;
133132}
134133
135134fn terminate_subprocesses ( sys : & System , process : & Process ) {
@@ -193,6 +192,6 @@ fn check_store() {
193192 eprintln ! ( "{}" , t!( "main.storeMessage" ) ) ;
194193 // wait for keypress
195194 let _ = io:: stdin ( ) . read ( & mut [ 0u8 ] ) . unwrap ( ) ;
196- exit ( util :: EXIT_INVALID_ARGS ) ;
195+ exit ( EXIT_INVALID_ARGS ) ;
197196 }
198197}
0 commit comments