From 3a827ea69ea259812cbf777ae10f4cae48988107 Mon Sep 17 00:00:00 2001 From: devrel-ditto <262946657+devrel-ditto@users.noreply.github.com> Date: Fri, 20 Mar 2026 23:18:53 +0000 Subject: [PATCH] fix: node info accepts --rpc-url as fallback for --ip The node info command required --ip while every other command uses the global --rpc-url flag. Now node info checks --ip first, then falls back to --rpc-url, making it consistent with the rest of the CLI. --ip is preserved for backward compatibility. Fixes #24 --- cmd/node.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/node.go b/cmd/node.go index 14d9c40..181ee31 100644 --- a/cmd/node.go +++ b/cmd/node.go @@ -18,16 +18,23 @@ var nodeIP string var nodeInfoCmd = &cobra.Command{ Use: "info", Short: "Get node information", - Long: `Get node ID and BLS public key from an avalanchego node.`, + Long: `Get node ID and BLS public key from an avalanchego node. + +Accepts --ip (IP or IP:port) or the global --rpc-url flag. +When both are provided, --ip takes precedence.`, RunE: func(cmd *cobra.Command, args []string) error { ctx, cancel := getOperationContext() defer cancel() - if nodeIP == "" { - return fmt.Errorf("--ip is required") + addr := nodeIP + if addr == "" && customRPCURL != "" { + addr = customRPCURL + } + if addr == "" { + return fmt.Errorf("--ip or --rpc-url is required") } - info, err := node.GetNodeInfoWithInsecureHTTP(ctx, nodeIP, allowInsecureHTTP) + info, err := node.GetNodeInfoWithInsecureHTTP(ctx, addr, allowInsecureHTTP) if err != nil { return fmt.Errorf("failed to get node info: %w", err) } @@ -43,5 +50,5 @@ func init() { rootCmd.AddCommand(nodeCmd) nodeCmd.AddCommand(nodeInfoCmd) - nodeInfoCmd.Flags().StringVar(&nodeIP, "ip", "", "Node IP address") + nodeInfoCmd.Flags().StringVar(&nodeIP, "ip", "", "Node IP or IP:port (also accepts --rpc-url)") }