public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Filip Schauer <f.schauer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v7 vma-to-pbs 5/9] add a fallback for the --fingerprint argument
Date: Tue,  9 Apr 2024 14:14:19 +0200	[thread overview]
Message-ID: <20240409121423.168627-6-f.schauer@proxmox.com> (raw)
In-Reply-To: <20240409121423.168627-1-f.schauer@proxmox.com>

Fallback to the PBS_FINGERPRINT environment variable if the
--fingerprint argument is not specified.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
 Cargo.toml  | 2 +-
 src/main.rs | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 50c60db..fa574c9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,7 @@ edition = "2021"
 [dependencies]
 anyhow = "1.0"
 bincode = "1.3"
-clap = { version = "4.0.32", features = ["cargo"] }
+clap = { version = "4.0.32", features = ["cargo", "env"] }
 md5 = "0.7.0"
 scopeguard = "1.1.0"
 serde = "1.0"
diff --git a/src/main.rs b/src/main.rs
index aa76ce1..cce9718 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -27,7 +27,7 @@ fn main() -> Result<()> {
                 .long("fingerprint")
                 .value_name("FINGERPRINT")
                 .help("Proxmox Backup Server Fingerprint")
-                .required(true),
+                .env("PBS_FINGERPRINT"),
         )
         .arg(
             Arg::new("keyfile")
@@ -72,9 +72,10 @@ fn main() -> Result<()> {
 
     let pbs_repository = matches.get_one::<String>("repository").unwrap().to_string();
     let vmid = matches.get_one::<String>("vmid").unwrap().to_string();
+
     let fingerprint = matches
         .get_one::<String>("fingerprint")
-        .unwrap()
+        .context("Fingerprint not set. Use $PBS_FINGERPRINT or --fingerprint")?
         .to_string();
 
     let keyfile = matches.get_one::<String>("keyfile");
-- 
2.39.2





  parent reply	other threads:[~2024-04-09 12:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 12:14 [pbs-devel] [PATCH v7 vma-to-pbs 0/9] Implement vma-to-pbs tool Filip Schauer
2024-04-09 12:14 ` [pbs-devel] [PATCH v7 vma-to-pbs 1/9] add the ability to provide credentials via files Filip Schauer
2024-04-09 12:14 ` [pbs-devel] [PATCH v7 vma-to-pbs 2/9] bump proxmox-backup-qemu Filip Schauer
2024-04-09 12:14 ` [pbs-devel] [PATCH v7 vma-to-pbs 3/9] remove unnecessary "extern crate" declarations Filip Schauer
2024-04-09 12:14 ` [pbs-devel] [PATCH v7 vma-to-pbs 4/9] add support for streaming the VMA file via stdin Filip Schauer
2024-04-09 12:14 ` Filip Schauer [this message]
2024-04-09 12:14 ` [pbs-devel] [PATCH v7 vma-to-pbs 6/9] refactor error handling Filip Schauer
2024-04-09 12:14 ` [pbs-devel] [PATCH v7 vma-to-pbs 7/9] makefile: remove reference to unused submodule Filip Schauer
2024-04-09 12:14 ` [pbs-devel] [PATCH v7 vma-to-pbs 8/9] switch argument handling from clap to pico-args Filip Schauer
2024-04-09 12:14 ` [pbs-devel] [PATCH v7 vma-to-pbs 9/9] reformat command line arguments to kebab-case Filip Schauer
2024-04-09 13:00 ` [pbs-devel] applied-series: [PATCH v7 vma-to-pbs 0/9] Implement vma-to-pbs tool Wolfgang Bumiller
2024-04-09 13:20 ` [pbs-devel] " Max Carrara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240409121423.168627-6-f.schauer@proxmox.com \
    --to=f.schauer@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal