summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 13e4cd2..5fc638b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -55,9 +55,6 @@ fn setup_logger() -> Result<(), fern::InitError> {
thread_id.hash(&mut hasher);
let thread_color = thread_colors[hasher.finish() as usize % thread_colors.len()];
- // if thread_id.find("ThreadId(") {
- // }
- // TODO: Make a random color based on the thread name.
out.finish(format_args!(
"[{}] \x1B[{}m{}@{}\x1B[0m {}",
colors.color(record.level()),
@@ -92,11 +89,23 @@ fn main() {
.help("Endpoint for this web server"),
)
.arg(
+ Arg::with_name("template_path")
+ .long("template_path")
+ .takes_value(true)
+ .help("Path to directory containing templates"),
+ )
+ .arg(
Arg::with_name("static_path")
.long("static_path")
.takes_value(true)
.help("Directory containing static files"),
)
+ .arg(
+ Arg::with_name("port")
+ .long("port")
+ .takes_value(true)
+ .help("Port to serve http user requests"),
+ )
.subcommand(
SubCommand::with_name("init")
.about("initialize database config")
@@ -135,11 +144,18 @@ fn main() {
setup_logger().expect("logger");
+
+ let static_path = matches.value_of("static_path").unwrap_or("./static");
+ let port: u16 = matches.value_of("port").unwrap_or("8000").parse().unwrap();
+
+ let default_base_url = format!("http://localhost:{}", port);
let base_url = matches
.value_of("base_url")
- .unwrap_or("http://localhost:8000");
+ .unwrap_or(&default_base_url);
- let static_path = matches.value_of("static_path").unwrap_or("./static");
+ let template_path = matches
+ .value_of("template_path")
+ .unwrap_or("./templates/");
let db_url = matches.value_of("database_url").unwrap();
let conn = PgConnection::establish(db_url).unwrap();
@@ -176,6 +192,6 @@ fn main() {
.expect("insert");
} else {
info!("Start server");
- pjournal::server::start(conn, db_url, base_url, static_path);
+ pjournal::server::start(conn, db_url, base_url, static_path, port, template_path);
}
}