@ -3,13 +3,15 @@ package shell
import (
import (
"context"
"context"
"fmt"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/operation"
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/needle_map"
"io"
"net/url"
"net/url"
"strconv"
"strconv"
"strings"
"strings"
"github.com/seaweedfs/seaweedfs/weed/operation"
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/needle_map"
"google.golang.org/grpc"
"google.golang.org/grpc"
"github.com/seaweedfs/seaweedfs/weed/pb"
"github.com/seaweedfs/seaweedfs/weed/pb"
@ -147,6 +149,37 @@ func findInputDirectory(args []string) (input string) {
return input
return input
}
}
// isHelpRequest checks if the args contain a help flag (-h, --help, or -help)
// It also handles combined short flags like -lh or -hl
func isHelpRequest ( args [ ] string ) bool {
for _ , arg := range args {
// Check for exact matches
if arg == "-h" || arg == "--help" || arg == "-help" {
return true
}
// Check for combined short flags (e.g., -lh, -hl, -rfh)
// Limit to reasonable length (2-4 chars total) to avoid matching long options like -verbose
if strings . HasPrefix ( arg , "-" ) && ! strings . HasPrefix ( arg , "--" ) && len ( arg ) > 1 && len ( arg ) <= 4 {
for _ , char := range arg [ 1 : ] {
if char == 'h' {
return true
}
}
}
}
return false
}
// handleHelpRequest checks for help flags and prints the help message if requested.
// It returns true if the help message was printed, indicating the command should exit.
func handleHelpRequest ( c command , args [ ] string , writer io . Writer ) bool {
if isHelpRequest ( args ) {
fmt . Fprintln ( writer , c . Help ( ) )
return true
}
return false
}
func readNeedleMeta ( grpcDialOption grpc . DialOption , volumeServer pb . ServerAddress , volumeId uint32 , needleValue needle_map . NeedleValue ) ( resp * volume_server_pb . ReadNeedleMetaResponse , err error ) {
func readNeedleMeta ( grpcDialOption grpc . DialOption , volumeServer pb . ServerAddress , volumeId uint32 , needleValue needle_map . NeedleValue ) ( resp * volume_server_pb . ReadNeedleMetaResponse , err error ) {
err = operation . WithVolumeServerClient ( false , volumeServer , grpcDialOption ,
err = operation . WithVolumeServerClient ( false , volumeServer , grpcDialOption ,
func ( client volume_server_pb . VolumeServerClient ) error {
func ( client volume_server_pb . VolumeServerClient ) error {