diff --git a/src/command/commands.rs b/src/command/commands.rs deleted file mode 100644 index 0bbf73e4..00000000 --- a/src/command/commands.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::command::init::InitCommand; -use crate::command::run::RunCommand; -use clap::Parser; - -#[derive(Parser, Debug)] -#[clap(author, version, about, long_about = None)] -pub struct Command { - #[clap(subcommand)] - pub action: SubCommand, -} - -#[derive(clap::Subcommand, Debug)] -pub enum SubCommand { - /// 설정 파일 및 저장공간 초기화 - Init(InitCommand), - /// DB 서버 실행 - Run(RunCommand), - /// DB 클라이언트 실행 - Client, -} diff --git a/src/command/init.rs b/src/command/init.rs index 7eb50334..69cefa1d 100644 --- a/src/command/init.rs +++ b/src/command/init.rs @@ -4,11 +4,15 @@ use clap::Args; /// Config options for the build system. #[derive(Clone, Debug, Default, Deserialize, Args)] -pub struct ConfigOptionsInit {} +pub struct ConfigOptions { + /// 파일이 세팅될 경로 + #[clap(long, short)] + pub config_path: Option, +} #[derive(Clone, Debug, Args)] #[clap(name = "init")] -pub struct InitCommand { +pub struct Command { #[clap(flatten)] - pub init: ConfigOptionsInit, + pub init: ConfigOptions, } diff --git a/src/command/mod.rs b/src/command/mod.rs index 8e318d2d..72509de2 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -1,8 +1,21 @@ -pub mod commands; -pub use commands::*; - pub mod init; -pub use init::*; - pub mod run; -pub use run::*; + +use clap::Parser; + +#[derive(Parser, Debug)] +#[clap(author, version, about, long_about = None)] +pub struct Command { + #[clap(subcommand)] + pub action: SubCommand, +} + +#[derive(clap::Subcommand, Debug)] +pub enum SubCommand { + /// 설정 파일 및 저장공간 초기화 + Init(init::Command), + /// DB 서버 실행 + Run(run::Command), + /// DB 클라이언트 실행 + Client, +} diff --git a/src/command/run.rs b/src/command/run.rs index 72062c76..db21cc98 100644 --- a/src/command/run.rs +++ b/src/command/run.rs @@ -4,19 +4,28 @@ use clap::Args; /// Config options for the build system. #[derive(Clone, Debug, Default, Deserialize, Args)] -pub struct ConfigOptionsRun { - /// 포트 - #[clap(name = "port", long)] - pub port: Option, +pub struct ConfigOptions { + #[clap( + name = "port", + default_value = "55555", + long, + short, + help = "Port to listen on" + )] + pub port: u32, - /// 호스트 - #[clap(name = "host", long)] - pub host: Option, + #[clap( + name = "host", + default_value = "0.0.0.0", + long, + help = "Hostname to listen on (IP or domain)" + )] + pub host: String, } #[derive(Clone, Debug, Args)] #[clap(name = "run")] -pub struct RunCommand { +pub struct Command { #[clap(flatten)] - pub value: ConfigOptionsRun, + pub value: ConfigOptions, } diff --git a/src/constants/mod.rs b/src/constants/mod.rs index a49b8359..309ae6fd 100644 --- a/src/constants/mod.rs +++ b/src/constants/mod.rs @@ -1,2 +1 @@ pub mod predule; -pub mod server; diff --git a/src/constants/predule.rs b/src/constants/predule.rs index 02dd7df7..8b137891 100644 --- a/src/constants/predule.rs +++ b/src/constants/predule.rs @@ -1 +1 @@ -pub use super::server::*; + diff --git a/src/constants/server.rs b/src/constants/server.rs deleted file mode 100644 index 94065dd8..00000000 --- a/src/constants/server.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub const DEFAULT_PORT: u32 = 55555; -pub const DEFAULT_HOST: &str = "0.0.0.0"; diff --git a/src/main.rs b/src/main.rs index 92498281..53d8d991 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,8 +13,7 @@ pub mod pgwire; pub mod server; pub mod utils; -use command::commands::{Command, SubCommand}; -use constants::predule::{DEFAULT_HOST, DEFAULT_PORT}; +use command::{Command, SubCommand}; use executor::predule::Executor; use server::predule::{Server, ServerOption}; @@ -34,8 +33,8 @@ async fn main() -> Result<(), Box> { } SubCommand::Run(run) => { let server_option = ServerOption { - port: run.value.port.unwrap_or(DEFAULT_PORT), - host: run.value.host.unwrap_or_else(|| DEFAULT_HOST.into()), + port: run.value.port, + host: run.value.host, }; let server = Server::new(server_option);