@@ -26,7 +26,7 @@ mod telemetry;
26
26
use crate :: options:: Options ;
27
27
use crate :: telemetry:: init_telemetry;
28
28
29
- use clap:: Parser ;
29
+ use clap:: { Parser , Subcommand } ;
30
30
31
31
use deadpool_diesel:: postgres:: { Pool , Runtime } ;
32
32
use deadpool_diesel:: Manager ;
@@ -46,6 +46,8 @@ use tracing::{error, info};
46
46
#[ derive( Parser , Debug ) ]
47
47
#[ command( about, long_about = None ) ]
48
48
struct Args {
49
+ #[ command( subcommand) ]
50
+ command : Option < Commands > ,
49
51
/// Config file
50
52
#[ arg( short, long, default_value = "config/default.toml" ) ]
51
53
config_path : Vec < String > ,
@@ -54,6 +56,12 @@ struct Args {
54
56
version : bool ,
55
57
}
56
58
59
+ #[ derive( Subcommand , Clone , Debug ) ]
60
+ enum Commands {
61
+ /// Print config
62
+ Config ,
63
+ }
64
+
57
65
/// Entry point for running the server.
58
66
#[ tokio:: main]
59
67
async fn main ( ) {
@@ -62,14 +70,20 @@ async fn main() {
62
70
println ! ( env!( "APP_VERSION" ) ) ;
63
71
return ;
64
72
}
73
+
65
74
let options = match Options :: new ( args. config_path ) {
66
75
Ok ( options) => options,
67
76
Err ( err) => {
68
- error ! ( "Failed to load config: {}" , err) ;
77
+ println ! ( "Failed to load config: {}" , err) ;
69
78
return ;
70
79
}
71
80
} ;
72
81
82
+ if let Some ( Commands :: Config ) = args. command {
83
+ println ! ( "{:#?}" , options) ;
84
+ return ;
85
+ }
86
+
73
87
init_telemetry (
74
88
options. service_name . as_str ( ) ,
75
89
options. exporter_endpoint . as_str ( ) ,
0 commit comments