1616 *
1717 */
1818
19+ use clap:: Parser ;
1920use crossterm:: style:: Stylize ;
2021use std:: path:: PathBuf ;
2122use std:: sync:: Arc ;
22- use structopt:: StructOpt ;
2323
2424use crate :: banner;
2525use crate :: s3:: S3Config ;
@@ -28,7 +28,7 @@ use crate::storage::{ObjectStorage, ObjectStorageError, LOCAL_SYNC_INTERVAL};
2828lazy_static:: lazy_static! {
2929 #[ derive( Debug ) ]
3030 pub static ref CONFIG : Arc <Config > = {
31- let storage = Box :: new( S3Config :: from_args ( ) ) ;
31+ let storage = Box :: new( S3Config :: parse ( ) ) ;
3232 Arc :: new( Config :: new( storage) )
3333 } ;
3434}
@@ -53,7 +53,7 @@ pub struct Config {
5353impl Config {
5454 fn new ( storage : Box < dyn StorageOpt > ) -> Config {
5555 Config {
56- parseable : Opt :: from_args ( ) ,
56+ parseable : Opt :: parse ( ) ,
5757 storage,
5858 }
5959 }
@@ -91,7 +91,7 @@ impl Config {
9191 "Failed to authenticate. Please ensure credentials are valid\n Caused by: {cause}" ,
9292 cause = inner
9393 ) ,
94- Err ( error) => { panic ! ( "{error}" ) }
94+ Err ( error) => { panic ! ( "{error}" ) }
9595 }
9696 }
9797
@@ -164,41 +164,41 @@ impl Config {
164164 }
165165}
166166
167- #[ derive( Debug , Clone , StructOpt ) ]
168- #[ structopt (
167+ #[ derive( Debug , Clone , Parser ) ]
168+ #[ command (
169169 name = "Parseable config" ,
170170 about = "configuration for Parseable server"
171171) ]
172172pub struct Opt {
173173 /// The location of TLS Cert file
174- #[ structopt ( long, env = "P_TLS_CERT_PATH" ) ]
174+ #[ arg ( long, env = "P_TLS_CERT_PATH" ) ]
175175 pub tls_cert_path : Option < PathBuf > ,
176176
177177 /// The location of TLS Private Key file
178- #[ structopt ( long, env = "P_TLS_KEY_PATH" ) ]
178+ #[ arg ( long, env = "P_TLS_KEY_PATH" ) ]
179179 pub tls_key_path : Option < PathBuf > ,
180180
181181 /// The address on which the http server will listen.
182- #[ structopt ( long, env = "P_ADDR" , default_value = "0.0.0.0:8000" ) ]
182+ #[ arg ( long, env = "P_ADDR" , default_value = "0.0.0.0:8000" ) ]
183183 pub address : String ,
184184
185185 /// The local storage path is used as temporary landing point
186186 /// for incoming events and local cache while querying data pulled
187187 /// from object storage backend
188- #[ structopt ( long, env = "P_LOCAL_STORAGE" , default_value = "./data" ) ]
188+ #[ arg ( long, env = "P_LOCAL_STORAGE" , default_value = "./data" ) ]
189189 pub local_disk_path : PathBuf ,
190190
191191 /// Optional interval after which server would upload uncommited data to
192192 /// remote object storage platform. Defaults to 1min.
193- #[ structopt ( long, env = "P_STORAGE_UPLOAD_INTERVAL" , default_value = "60" ) ]
193+ #[ arg ( long, env = "P_STORAGE_UPLOAD_INTERVAL" , default_value = "60" ) ]
194194 pub upload_interval : u64 ,
195195
196196 /// Optional username to enable basic auth on the server
197- #[ structopt ( long, env = USERNAME_ENV , default_value = DEFAULT_USERNAME ) ]
197+ #[ arg ( long, env = USERNAME_ENV , default_value = DEFAULT_USERNAME ) ]
198198 pub username : String ,
199199
200200 /// Optional password to enable basic auth on the server
201- #[ structopt ( long, env = PASSOWRD_ENV , default_value = DEFAULT_PASSWORD ) ]
201+ #[ arg ( long, env = PASSOWRD_ENV , default_value = DEFAULT_PASSWORD ) ]
202202 pub password : String ,
203203}
204204
0 commit comments