Skip to content

Commit 1266fe5

Browse files
committed
feat: allow customization of host and port for cli
1 parent a1cd762 commit 1266fe5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

datafusion-postgres-cli/src/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ struct Opt {
3030
/// Avro files to register as table, using syntax `table_name:file_path`
3131
#[structopt(long("avro"))]
3232
avro_tables: Vec<String>,
33+
/// Port the server listens to, default to 5432
34+
#[structopt(short, default_value = "5432")]
35+
port: u16,
36+
/// Host address the server listens to, default to 127.0.0.1
37+
#[structopt(long("host"), default_value = "127.0.0.1")]
38+
host: String,
3339
}
3440

3541
fn parse_table_def(table_def: &str) -> (&str, &str) {
@@ -96,8 +102,8 @@ async fn main() {
96102
session_context,
97103
))));
98104

99-
let server_addr = "127.0.0.1:5432";
100-
let listener = TcpListener::bind(server_addr).await.unwrap();
105+
let server_addr = format!("{}:{}", opts.host, opts.port);
106+
let listener = TcpListener::bind(&server_addr).await.unwrap();
101107
println!("Listening to {}", server_addr);
102108
loop {
103109
let incoming_socket = listener.accept().await.unwrap();

0 commit comments

Comments
 (0)