From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 6152A1FF16B for ; Tue, 12 Aug 2025 11:55:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DA49692E2; Tue, 12 Aug 2025 11:57:16 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Tue, 12 Aug 2025 11:56:27 +0200 Message-ID: <20250812095637.444463-4-c.heiss@proxmox.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812095637.444463-1-c.heiss@proxmox.com> References: <20250812095637.444463-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1754992573040 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, resthandler.pm, clihandler.pm] Subject: [pve-devel] [PATCH common 3/3] fix #6656: cli handler: generate anchors for all (sub-)commands X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" First part of fixing #6656 [0]. The `cli_` prefix here is chosen to make them unambiguous. For example, anchors for subsections in the QEMU top-level section are named `qm_`, which could potentially introduce conflicts without the prefix. [0] https://bugzilla.proxmox.com/show_bug.cgi?id=6656 Signed-off-by: Christoph Heiss --- src/PVE/CLIHandler.pm | 9 ++++++--- src/PVE/RESTHandler.pm | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm index 82118a8..89cb7b7 100644 --- a/src/PVE/CLIHandler.pm +++ b/src/PVE/CLIHandler.pm @@ -233,7 +233,9 @@ sub generate_usage_str { $oldclass = $class; } elsif (defined($def->{$cmd}->{alias}) && ($format eq 'asciidoc')) { - + my $safeprefix = $prefix =~ s/\s/_/rg; + my $safecmd = $cmd =~ s/\s/_/rg; + $str .= "[[cli_${safeprefix}_${safecmd}]]\n"; $str .= "*$prefix $cmd*\n\nAn alias for '$prefix $def->{$cmd}->{alias}'.\n\n"; @@ -336,7 +338,8 @@ __PACKAGE__->register_method({ sub print_simple_asciidoc_synopsis { $assert_initialized->(); - my $synopsis = "*${exename}* `help`\n\n"; + my $synopsis = "[[cli_${exename}_help]]\n"; + $synopsis .= "*${exename}* `help`\n\n"; $synopsis .= generate_usage_str('asciidoc'); return $synopsis; @@ -345,7 +348,7 @@ sub print_simple_asciidoc_synopsis { sub print_asciidoc_synopsis { $assert_initialized->(); - my $synopsis = ""; + my $synopsis = "[[cli_${exename}]]\n"; $synopsis .= "*${exename}* ` [ARGS] [OPTIONS]`\n\n"; diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm index 4c31ea1..82e6db5 100644 --- a/src/PVE/RESTHandler.pm +++ b/src/PVE/RESTHandler.pm @@ -820,6 +820,8 @@ sub getopt_usage { } if ($format eq 'asciidoc') { + my $safeprefix = $prefix =~ s/\s/_/rg; + $out .= "[[cli_${safeprefix}]]\n"; $out .= "*${prefix}*"; $out .= " `$args`" if $args; $out .= " `[OPTIONS]`" if $opts; -- 2.50.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel