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>,
|
||||
#[arg(long, conflicts_with = "local_ip")]
|
||||
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)]
|
||||
local_share: Option<String>,
|
||||
#[arg(long)]
|
||||
@@ -72,6 +74,8 @@ pub struct DriveArgs {
|
||||
cloud_kind: Option<MountKind>,
|
||||
#[arg(long)]
|
||||
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)]
|
||||
cloud_share: Option<String>,
|
||||
#[arg(long)]
|
||||
@@ -90,6 +94,18 @@ pub struct DriveArgs {
|
||||
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<()> {
|
||||
match action {
|
||||
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_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)?
|
||||
.expect("required");
|
||||
let local_share = resolve_field(
|
||||
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_username, local_password) = resolve_credentials(
|
||||
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_host = resolve_field(args.cloud_host, None, "Cloud server address/URL", ni, true)?
|
||||
.expect("required");
|
||||
let cloud_share = resolve_field(args.cloud_share, None, "Cloud share/export path", ni, true)?
|
||||
.expect("required");
|
||||
let cloud_share = resolve_field(
|
||||
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_username, cloud_password) = resolve_credentials(
|
||||
cloud_kind,
|
||||
@@ -272,7 +300,7 @@ async fn edit(id: &str, args: DriveArgs) -> anyhow::Result<()> {
|
||||
let local_share = resolve_field(
|
||||
args.local_share,
|
||||
Some(&existing.local.share),
|
||||
"Local share/export path",
|
||||
&share_field_label(local_kind, "Local"),
|
||||
ni,
|
||||
true,
|
||||
)?
|
||||
@@ -307,7 +335,7 @@ async fn edit(id: &str, args: DriveArgs) -> anyhow::Result<()> {
|
||||
let cloud_share = resolve_field(
|
||||
args.cloud_share,
|
||||
Some(&existing.cloud.share),
|
||||
"Cloud share/export path",
|
||||
&share_field_label(cloud_kind, "Cloud"),
|
||||
ni,
|
||||
true,
|
||||
)?
|
||||
|
||||
Reference in New Issue
Block a user