feature/fix-required-args #40

Merged
kjuulh merged 2 commits from feature/fix-required-args into v0.3 2022-11-27 21:10:41 +01:00
4 changed files with 11 additions and 4 deletions

View File

@ -0,0 +1 @@
dist/

Binary file not shown.

View File

@ -28,21 +28,21 @@ pub fn execute_cmd() -> Command {
.long("gitea-api-token") .long("gitea-api-token")
.action(ArgAction::Set) .action(ArgAction::Set)
.env("GITEA_API_TOKEN") .env("GITEA_API_TOKEN")
.required(false), .required(true),
) )
.arg( .arg(
Arg::new("gitea-username") Arg::new("gitea-username")
.long("gitea-username") .long("gitea-username")
.action(ArgAction::Set) .action(ArgAction::Set)
.env("GITEA_USERNAME") .env("GITEA_USERNAME")
.required(false), .required(true),
) )
.arg( .arg(
Arg::new("gitea-url") Arg::new("gitea-url")
.long("gitea-url") .long("gitea-url")
.action(ArgAction::Set) .action(ArgAction::Set)
.env("GITEA_URL") .env("GITEA_URL")
.required(false), .required(true),
) )
.arg( .arg(
Arg::new("github-api-token") Arg::new("github-api-token")

View File

@ -1,9 +1,15 @@
use dotenv::dotenv; use dotenv::dotenv;
use eyre::Context;
use tracing_subscriber::prelude::*; use tracing_subscriber::prelude::*;
#[tokio::main] #[tokio::main]
async fn main() -> eyre::Result<()> { async fn main() -> eyre::Result<()> {
dotenv()?; if let Err(e) = dotenv().context(".env file not found") {
tracing::info!(
error = e.to_string(),
"no .env file specified, command args are required"
);
}
tracing_subscriber::registry() tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::new( .with(tracing_subscriber::EnvFilter::new(