Fix: Klarere Feldbezeichnung für 'share'/Export-Pfad in 'drive add'/'edit'
Der generische Prompt-/Hilfetext "Local/Cloud share/export path" war unabhängig vom gewählten Mount-Typ identisch, obwohl das Feld inhaltlich je nach Backend etwas anderes ist (SMB-Freigabename, NFS-Export-Pfad, WebDAV-URL-Pfad). share_field_label() wählt jetzt passend zum bereits gewählten local_kind/cloud_kind einen eindeutigen Text mit Beispiel. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+34
-6
@@ -56,6 +56,8 @@ pub struct DriveArgs {
|
|||||||
local_ip: Option<Ipv4Addr>,
|
local_ip: Option<Ipv4Addr>,
|
||||||
#[arg(long, conflicts_with = "local_ip")]
|
#[arg(long, conflicts_with = "local_ip")]
|
||||||
local_mac: Option<String>,
|
local_mac: Option<String>,
|
||||||
|
/// Meaning depends on '--local-kind': the SMB share name (e.g. 'media'), the NFS export
|
||||||
|
/// path (e.g. '/export/media'), or the WebDAV URL path (e.g. '/remote.php/dav/files/user').
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
local_share: Option<String>,
|
local_share: Option<String>,
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
@@ -72,6 +74,8 @@ pub struct DriveArgs {
|
|||||||
cloud_kind: Option<MountKind>,
|
cloud_kind: Option<MountKind>,
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
cloud_host: Option<String>,
|
cloud_host: Option<String>,
|
||||||
|
/// Meaning depends on '--cloud-kind': the SMB share name (e.g. 'media'), the NFS export
|
||||||
|
/// path (e.g. '/export/media'), or the WebDAV URL path (e.g. '/remote.php/dav/files/user').
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
cloud_share: Option<String>,
|
cloud_share: Option<String>,
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
@@ -90,6 +94,18 @@ pub struct DriveArgs {
|
|||||||
non_interactive: bool,
|
non_interactive: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Beschriftet das `share`-Feld abhängig vom bereits gewählten Mount-Typ statt des
|
||||||
|
/// generischen "share/export path" - die drei Backends legen dort inhaltlich verschiedene
|
||||||
|
/// Dinge ab (SMB-Freigabename, NFS-Export-Pfad, WebDAV-URL-Pfad), siehe
|
||||||
|
/// `mount::target::format_source`.
|
||||||
|
fn share_field_label(kind: MountKind, prefix: &str) -> String {
|
||||||
|
match kind {
|
||||||
|
MountKind::WebDav => format!("{prefix} WebDAV path (e.g. '/remote.php/dav/files/user')"),
|
||||||
|
MountKind::Smb => format!("{prefix} share name (e.g. 'media')"),
|
||||||
|
MountKind::Nfs => format!("{prefix} export path (e.g. '/export/media')"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn run(action: DriveAction) -> anyhow::Result<()> {
|
pub async fn run(action: DriveAction) -> anyhow::Result<()> {
|
||||||
match action {
|
match action {
|
||||||
DriveAction::Add(args) => add(args).await,
|
DriveAction::Add(args) => add(args).await,
|
||||||
@@ -166,8 +182,14 @@ async fn add(args: DriveArgs) -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let local_kind = resolve_kind(args.local_kind, None, "Local mount type", ni)?;
|
let local_kind = resolve_kind(args.local_kind, None, "Local mount type", ni)?;
|
||||||
let local_address = resolve_local_address(args.local_ip, args.local_mac, None, ni)?;
|
let local_address = resolve_local_address(args.local_ip, args.local_mac, None, ni)?;
|
||||||
let local_share = resolve_field(args.local_share, None, "Local share/export path", ni, true)?
|
let local_share = resolve_field(
|
||||||
.expect("required");
|
args.local_share,
|
||||||
|
None,
|
||||||
|
&share_field_label(local_kind, "Local"),
|
||||||
|
ni,
|
||||||
|
true,
|
||||||
|
)?
|
||||||
|
.expect("required");
|
||||||
let local_password_flag = read_password_flag(args.local_password, args.local_password_stdin)?;
|
let local_password_flag = read_password_flag(args.local_password, args.local_password_stdin)?;
|
||||||
let (local_username, local_password) = resolve_credentials(
|
let (local_username, local_password) = resolve_credentials(
|
||||||
local_kind,
|
local_kind,
|
||||||
@@ -181,8 +203,14 @@ async fn add(args: DriveArgs) -> anyhow::Result<()> {
|
|||||||
let cloud_kind = resolve_kind(args.cloud_kind, None, "Cloud mount type", ni)?;
|
let cloud_kind = resolve_kind(args.cloud_kind, None, "Cloud mount type", ni)?;
|
||||||
let cloud_host = resolve_field(args.cloud_host, None, "Cloud server address/URL", ni, true)?
|
let cloud_host = resolve_field(args.cloud_host, None, "Cloud server address/URL", ni, true)?
|
||||||
.expect("required");
|
.expect("required");
|
||||||
let cloud_share = resolve_field(args.cloud_share, None, "Cloud share/export path", ni, true)?
|
let cloud_share = resolve_field(
|
||||||
.expect("required");
|
args.cloud_share,
|
||||||
|
None,
|
||||||
|
&share_field_label(cloud_kind, "Cloud"),
|
||||||
|
ni,
|
||||||
|
true,
|
||||||
|
)?
|
||||||
|
.expect("required");
|
||||||
let cloud_password_flag = read_password_flag(args.cloud_password, args.cloud_password_stdin)?;
|
let cloud_password_flag = read_password_flag(args.cloud_password, args.cloud_password_stdin)?;
|
||||||
let (cloud_username, cloud_password) = resolve_credentials(
|
let (cloud_username, cloud_password) = resolve_credentials(
|
||||||
cloud_kind,
|
cloud_kind,
|
||||||
@@ -272,7 +300,7 @@ async fn edit(id: &str, args: DriveArgs) -> anyhow::Result<()> {
|
|||||||
let local_share = resolve_field(
|
let local_share = resolve_field(
|
||||||
args.local_share,
|
args.local_share,
|
||||||
Some(&existing.local.share),
|
Some(&existing.local.share),
|
||||||
"Local share/export path",
|
&share_field_label(local_kind, "Local"),
|
||||||
ni,
|
ni,
|
||||||
true,
|
true,
|
||||||
)?
|
)?
|
||||||
@@ -307,7 +335,7 @@ async fn edit(id: &str, args: DriveArgs) -> anyhow::Result<()> {
|
|||||||
let cloud_share = resolve_field(
|
let cloud_share = resolve_field(
|
||||||
args.cloud_share,
|
args.cloud_share,
|
||||||
Some(&existing.cloud.share),
|
Some(&existing.cloud.share),
|
||||||
"Cloud share/export path",
|
&share_field_label(cloud_kind, "Cloud"),
|
||||||
ni,
|
ni,
|
||||||
true,
|
true,
|
||||||
)?
|
)?
|
||||||
|
|||||||
Reference in New Issue
Block a user