Browse Source

-c/--config CLI option

Signed-off-by: Alexey Yerin <yerinalexey98fd@gmail.com>
master v0.0.1
Alexey Yerin 4 years ago committed by Garrit Franke
parent
commit
2291c934c3
  1. 72
      Cargo.lock
  2. 2
      Cargo.toml
  3. 20
      src/main.rs

72
Cargo.lock generated

@ -1,11 +1,31 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi",
]
[[package]]
name = "anyhow"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7"
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.0.1"
@ -30,6 +50,21 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "clap"
version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "core-foundation"
version = "0.7.0"
@ -72,6 +107,15 @@ dependencies = [
"wasi",
]
[[package]]
name = "hermit-abi"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
dependencies = [
"libc",
]
[[package]]
name = "idna"
version = "0.2.0"
@ -306,6 +350,12 @@ dependencies = [
"syn",
]
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "syn"
version = "1.0.48"
@ -322,6 +372,7 @@ name = "taurus"
version = "0.0.1"
dependencies = [
"anyhow",
"clap",
"native-tls",
"serde",
"toml",
@ -342,6 +393,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "tinyvec"
version = "0.3.4"
@ -375,6 +435,12 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-width"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
version = "0.2.1"
@ -398,6 +464,12 @@ version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"

2
Cargo.toml

@ -1,5 +1,6 @@
[package]
name = "taurus"
description = "A concurrent gemini server"
version = "0.0.1"
authors = ["Garrit Franke <garritfranke@gmail.com>"]
edition = "2018"
@ -12,3 +13,4 @@ native-tls = "0.2.4"
serde = { version = "1.0.117", features = ["derive"] }
toml = "0.5.7"
anyhow = "1.0.34"
clap = "2.33.3"

20
src/main.rs

@ -13,8 +13,26 @@ use std::path;
use std::sync::Arc;
use std::thread;
use clap::{crate_authors, crate_description, crate_name, crate_version, App, Arg};
fn main() -> Result<(), error::SimpleError> {
let config: config::Config = config::Config::load(None)
// CLI
let matches = App::new(crate_name!())
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
.arg(
Arg::with_name("config")
.long("config")
.short("c")
.help("Alternative config file location [default /etc/taurus/taurus.toml]")
.next_line_help(true)
.value_name("FILE"),
)
.get_matches();
let config_path = matches.value_of("config").map(|v| v.to_owned());
let config: config::Config = config::Config::load(config_path)
.map_err(|err| format!("failed to read configuration file: {}", err))?;
// Defaults for configuration file

Loading…
Cancel
Save