cli: Fix command line arguments. Allow using ENV vars
Diff
Cargo.toml | 3 ++-
docker-compose.yml | 6 ++----
src/main.rs | 21 ++++++++++++++++-----
scripts/docker/entrypoint.sh | 8 +-------
4 files changed, 16 insertions(+), 22 deletions(-)
@@ -30,6 +30,7 @@
"std",
"cargo",
"derive",
"env",
"help",
"usage",
] }
@@ -60,7 +61,7 @@
"bytecheck",
"alloc",
], default-features = false }
rocksdb = { version = "0.23", default-features = false, features = ["snappy"] }
rocksdb = { version = "0.24", default-features = false, features = ["snappy"] }
serde = { version = "1.0", features = ["derive", "rc"] }
simdutf8 = "0.1.5"
tar = { version = "0.4", default-features = false }
@@ -1,15 +1,13 @@
version: '3'
services:
rgit:
image: ghcr.io/w4/rgit:main
command:
- "[::]:8000"
- /git
- -d /tmp/rgit-cache.db
volumes:
- /volume/git:/git
ports:
- 8000:8000
environment:
- REFRESH_INTERVAL=5m
- DB_STORE=/tmp/rgit.db
- SCAN_PATH=/git
restart: unless-stopped
@@ -1,10 +1,10 @@
#![deny(clippy::pedantic)]
use std::{
borrow::Cow,
fmt::{Display, Formatter},
future::IntoFuture,
net::SocketAddr,
net::{IpAddr, Ipv6Addr, SocketAddr},
path::PathBuf,
str::FromStr,
sync::{Arc, OnceLock},
@@ -72,24 +72,25 @@
#[derive(Parser, Debug)]
#[clap(author, version, about)]
pub struct Args {
#[clap(short, long, env="SCAN_PATH", value_parser)]
scan_path: PathBuf,
#[clap(short, long, env="BIND_ADDRESS", default_value_t = SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)), 8080), value_parser)]
bind_address: SocketAddr,
#[clap(short, long, value_parser)]
#[clap(short, long, env="DB_STORE", value_parser)]
db_store: PathBuf,
bind_address: SocketAddr,
scan_path: PathBuf,
#[clap(long)]
#[clap(long, env="REPOSITORY_LIST")]
repository_list: Option<PathBuf>,
#[clap(long, default_value_t = RefreshInterval::Duration(Duration::from_secs(300)))]
#[clap(long, env="REFRESH_INTERVAL", default_value_t = RefreshInterval::Duration(Duration::from_secs(300)))]
refresh_interval: RefreshInterval,
#[clap(long, default_value_t = Duration::from_secs(10).into())]
#[clap(long, env="REQUEST_TIMEOUT", default_value_t = Duration::from_secs(10).into())]
request_timeout: humantime::Duration,
}
@@ -1,8 +1,2 @@
if [ -z ${REFRESH_INTERVAL+x} ];
then
./rgit "[::]:8000" /git -d /tmp/rgit-cache.db;
else
./rgit "[::]:8000" /git -d /tmp/rgit-cache.db --refresh-interval "$REFRESH_INTERVAL";
fi
./rgit "[::]:8000" /git -d /tmp/rgit-cache.db;