Add base configuration (#1)
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone Build is passing
				
			Reviewed-on: #1
This commit is contained in:
		
							
								
								
									
										47
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								src/main.rs
									
									
									
									
									
								
							@@ -1,3 +1,50 @@
 | 
			
		||||
use clap::Parser;
 | 
			
		||||
 | 
			
		||||
/// Basic OpenID test client
 | 
			
		||||
#[derive(Parser, Debug)]
 | 
			
		||||
struct AppConfig {
 | 
			
		||||
    /// Listen URL
 | 
			
		||||
    #[arg(short, long, env, default_value = "0.0.0.0:7510")]
 | 
			
		||||
    listen_addr: String,
 | 
			
		||||
 | 
			
		||||
    /// Public URL, the URL where this service is accessible, without the trailing slash
 | 
			
		||||
    #[arg(short, long, env, default_value = "http://localhost:7510")]
 | 
			
		||||
    public_url: String,
 | 
			
		||||
 | 
			
		||||
    /// URL where the OpenID configuration can be found
 | 
			
		||||
    #[arg(short, long, env)]
 | 
			
		||||
    configuration_url: String,
 | 
			
		||||
 | 
			
		||||
    /// OpenID client ID
 | 
			
		||||
    #[arg(long, env)]
 | 
			
		||||
    client_id: String,
 | 
			
		||||
 | 
			
		||||
    /// OpenID client secret
 | 
			
		||||
    #[arg(long, env)]
 | 
			
		||||
    client_secret: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
lazy_static::lazy_static! {
 | 
			
		||||
    static ref CONF: AppConfig = {
 | 
			
		||||
        AppConfig::parse()
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn main() {
 | 
			
		||||
    env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
 | 
			
		||||
 | 
			
		||||
    log::info!("Will listen on {}", CONF.listen_addr);
 | 
			
		||||
 | 
			
		||||
    println!("Hello, world!");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(test)]
 | 
			
		||||
mod test {
 | 
			
		||||
    use crate::AppConfig;
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn verify_cli() {
 | 
			
		||||
        use clap::CommandFactory;
 | 
			
		||||
        AppConfig::command().debug_assert();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user