bump
This commit is contained in:
1 parent
86d1db55cd
commit
a3c782eb24
11 files changed
+4904
-6
No files matched your search
@@ -41,6 +41,32 @@ func main() {
|
||||
clearAllSiteDataCmd := flag.NewFlagSet("clear-all-site-data", flag.ExitOnError)
|
||||
clearCookiesCmd := flag.NewFlagSet("clear-cookies", flag.ExitOnError)
|
||||
clearStorageCmd := flag.NewFlagSet("clear-storage", flag.ExitOnError)
|
||||
dragAndDropCmd := flag.NewFlagSet("drag-and-drop", flag.ExitOnError)
|
||||
dragAndDropCoordinatesCmd := flag.NewFlagSet("drag-and-drop-coordinates", flag.ExitOnError)
|
||||
dragAndDropOffsetCmd := flag.NewFlagSet("drag-and-drop-offset", flag.ExitOnError)
|
||||
|
||||
// Advanced mouse operations
|
||||
rightClickCmd := flag.NewFlagSet("right-click", flag.ExitOnError)
|
||||
doubleClickCmd := flag.NewFlagSet("double-click", flag.ExitOnError)
|
||||
middleClickCmd := flag.NewFlagSet("middle-click", flag.ExitOnError)
|
||||
hoverCmd := flag.NewFlagSet("hover", flag.ExitOnError)
|
||||
mouseMoveCmd := flag.NewFlagSet("mouse-move", flag.ExitOnError)
|
||||
scrollWheelCmd := flag.NewFlagSet("scroll-wheel", flag.ExitOnError)
|
||||
|
||||
// Keyboard operations
|
||||
keyCombinationCmd := flag.NewFlagSet("key-combination", flag.ExitOnError)
|
||||
specialKeyCmd := flag.NewFlagSet("special-key", flag.ExitOnError)
|
||||
modifierClickCmd := flag.NewFlagSet("modifier-click", flag.ExitOnError)
|
||||
|
||||
// Note: Touch operations and advanced scrolling/text operations are planned for future implementation
|
||||
// touchTapCmd := flag.NewFlagSet("touch-tap", flag.ExitOnError)
|
||||
// touchLongPressCmd := flag.NewFlagSet("touch-long-press", flag.ExitOnError)
|
||||
// touchSwipeCmd := flag.NewFlagSet("touch-swipe", flag.ExitOnError)
|
||||
// pinchZoomCmd := flag.NewFlagSet("pinch-zoom", flag.ExitOnError)
|
||||
// scrollElementCmd := flag.NewFlagSet("scroll-element", flag.ExitOnError)
|
||||
// scrollToCoordinatesCmd := flag.NewFlagSet("scroll-to-coordinates", flag.ExitOnError)
|
||||
// selectTextCmd := flag.NewFlagSet("select-text", flag.ExitOnError)
|
||||
// selectAllTextCmd := flag.NewFlagSet("select-all-text", flag.ExitOnError)
|
||||
|
||||
// Define flags for each subcommand
|
||||
// open-tab flags
|
||||
@@ -182,6 +208,104 @@ func main() {
|
||||
clearStorageHost := clearStorageCmd.String("host", "localhost", "Daemon host")
|
||||
clearStoragePort := clearStorageCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// drag-and-drop flags
|
||||
dragAndDropTabID := dragAndDropCmd.String("tab", "", "Tab ID to perform drag and drop on (optional, uses current tab if not specified)")
|
||||
dragAndDropSource := dragAndDropCmd.String("source", "", "CSS selector for the source element to drag")
|
||||
dragAndDropTarget := dragAndDropCmd.String("target", "", "CSS selector for the target element to drop on")
|
||||
dragAndDropTimeout := dragAndDropCmd.Int("timeout", 5, "Timeout in seconds for drag and drop operation")
|
||||
dragAndDropHost := dragAndDropCmd.String("host", "localhost", "Daemon host")
|
||||
dragAndDropPort := dragAndDropCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// drag-and-drop-coordinates flags
|
||||
dragAndDropCoordinatesTabID := dragAndDropCoordinatesCmd.String("tab", "", "Tab ID to perform drag and drop on (optional, uses current tab if not specified)")
|
||||
dragAndDropCoordinatesSource := dragAndDropCoordinatesCmd.String("source", "", "CSS selector for the source element to drag")
|
||||
dragAndDropCoordinatesX := dragAndDropCoordinatesCmd.Int("x", 0, "Target X coordinate")
|
||||
dragAndDropCoordinatesY := dragAndDropCoordinatesCmd.Int("y", 0, "Target Y coordinate")
|
||||
dragAndDropCoordinatesTimeout := dragAndDropCoordinatesCmd.Int("timeout", 5, "Timeout in seconds for drag and drop operation")
|
||||
dragAndDropCoordinatesHost := dragAndDropCoordinatesCmd.String("host", "localhost", "Daemon host")
|
||||
dragAndDropCoordinatesPort := dragAndDropCoordinatesCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// drag-and-drop-offset flags
|
||||
dragAndDropOffsetTabID := dragAndDropOffsetCmd.String("tab", "", "Tab ID to perform drag and drop on (optional, uses current tab if not specified)")
|
||||
dragAndDropOffsetSource := dragAndDropOffsetCmd.String("source", "", "CSS selector for the source element to drag")
|
||||
dragAndDropOffsetX := dragAndDropOffsetCmd.Int("offset-x", 0, "Horizontal offset in pixels")
|
||||
dragAndDropOffsetY := dragAndDropOffsetCmd.Int("offset-y", 0, "Vertical offset in pixels")
|
||||
dragAndDropOffsetTimeout := dragAndDropOffsetCmd.Int("timeout", 5, "Timeout in seconds for drag and drop operation")
|
||||
dragAndDropOffsetHost := dragAndDropOffsetCmd.String("host", "localhost", "Daemon host")
|
||||
dragAndDropOffsetPort := dragAndDropOffsetCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// right-click flags
|
||||
rightClickTabID := rightClickCmd.String("tab", "", "Tab ID to perform right-click on (optional, uses current tab if not specified)")
|
||||
rightClickSelector := rightClickCmd.String("selector", "", "CSS selector for the element to right-click")
|
||||
rightClickTimeout := rightClickCmd.Int("timeout", 5, "Timeout in seconds for right-click operation")
|
||||
rightClickHost := rightClickCmd.String("host", "localhost", "Daemon host")
|
||||
rightClickPort := rightClickCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// double-click flags
|
||||
doubleClickTabID := doubleClickCmd.String("tab", "", "Tab ID to perform double-click on (optional, uses current tab if not specified)")
|
||||
doubleClickSelector := doubleClickCmd.String("selector", "", "CSS selector for the element to double-click")
|
||||
doubleClickTimeout := doubleClickCmd.Int("timeout", 5, "Timeout in seconds for double-click operation")
|
||||
doubleClickHost := doubleClickCmd.String("host", "localhost", "Daemon host")
|
||||
doubleClickPort := doubleClickCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// middle-click flags
|
||||
middleClickTabID := middleClickCmd.String("tab", "", "Tab ID to perform middle-click on (optional, uses current tab if not specified)")
|
||||
middleClickSelector := middleClickCmd.String("selector", "", "CSS selector for the element to middle-click")
|
||||
middleClickTimeout := middleClickCmd.Int("timeout", 5, "Timeout in seconds for middle-click operation")
|
||||
middleClickHost := middleClickCmd.String("host", "localhost", "Daemon host")
|
||||
middleClickPort := middleClickCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// hover flags
|
||||
hoverTabID := hoverCmd.String("tab", "", "Tab ID to perform hover on (optional, uses current tab if not specified)")
|
||||
hoverSelector := hoverCmd.String("selector", "", "CSS selector for the element to hover over")
|
||||
hoverTimeout := hoverCmd.Int("timeout", 5, "Timeout in seconds for hover operation")
|
||||
hoverHost := hoverCmd.String("host", "localhost", "Daemon host")
|
||||
hoverPort := hoverCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// mouse-move flags
|
||||
mouseMoveTabID := mouseMoveCmd.String("tab", "", "Tab ID to move mouse on (optional, uses current tab if not specified)")
|
||||
mouseMoveX := mouseMoveCmd.Int("x", 0, "X coordinate to move mouse to")
|
||||
mouseMoveY := mouseMoveCmd.Int("y", 0, "Y coordinate to move mouse to")
|
||||
mouseMoveTimeout := mouseMoveCmd.Int("timeout", 5, "Timeout in seconds for mouse move operation")
|
||||
mouseMoveHost := mouseMoveCmd.String("host", "localhost", "Daemon host")
|
||||
mouseMovePort := mouseMoveCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// scroll-wheel flags
|
||||
scrollWheelTabID := scrollWheelCmd.String("tab", "", "Tab ID to scroll on (optional, uses current tab if not specified)")
|
||||
scrollWheelX := scrollWheelCmd.Int("x", 0, "X coordinate for scroll wheel")
|
||||
scrollWheelY := scrollWheelCmd.Int("y", 0, "Y coordinate for scroll wheel")
|
||||
scrollWheelDeltaX := scrollWheelCmd.Int("delta-x", 0, "Horizontal scroll delta (negative = left, positive = right)")
|
||||
scrollWheelDeltaY := scrollWheelCmd.Int("delta-y", 0, "Vertical scroll delta (negative = up, positive = down)")
|
||||
scrollWheelTimeout := scrollWheelCmd.Int("timeout", 5, "Timeout in seconds for scroll wheel operation")
|
||||
scrollWheelHost := scrollWheelCmd.String("host", "localhost", "Daemon host")
|
||||
scrollWheelPort := scrollWheelCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// key-combination flags
|
||||
keyCombinationTabID := keyCombinationCmd.String("tab", "", "Tab ID to send key combination to (optional, uses current tab if not specified)")
|
||||
keyCombinationKeys := keyCombinationCmd.String("keys", "", "Key combination to send (e.g., 'Ctrl+C', 'Alt+Tab', 'Shift+Enter')")
|
||||
keyCombinationTimeout := keyCombinationCmd.Int("timeout", 5, "Timeout in seconds for key combination operation")
|
||||
keyCombinationHost := keyCombinationCmd.String("host", "localhost", "Daemon host")
|
||||
keyCombinationPort := keyCombinationCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// special-key flags
|
||||
specialKeyTabID := specialKeyCmd.String("tab", "", "Tab ID to send special key to (optional, uses current tab if not specified)")
|
||||
specialKeyKey := specialKeyCmd.String("key", "", "Special key to send (e.g., 'Enter', 'Escape', 'Tab', 'F1', 'ArrowUp')")
|
||||
specialKeyTimeout := specialKeyCmd.Int("timeout", 5, "Timeout in seconds for special key operation")
|
||||
specialKeyHost := specialKeyCmd.String("host", "localhost", "Daemon host")
|
||||
specialKeyPort := specialKeyCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// modifier-click flags
|
||||
modifierClickTabID := modifierClickCmd.String("tab", "", "Tab ID to perform modifier click on (optional, uses current tab if not specified)")
|
||||
modifierClickSelector := modifierClickCmd.String("selector", "", "CSS selector for the element to click")
|
||||
modifierClickModifiers := modifierClickCmd.String("modifiers", "", "Modifier keys (e.g., 'Ctrl', 'Shift', 'Alt', 'Ctrl+Shift')")
|
||||
modifierClickTimeout := modifierClickCmd.Int("timeout", 5, "Timeout in seconds for modifier click operation")
|
||||
modifierClickHost := modifierClickCmd.String("host", "localhost", "Daemon host")
|
||||
modifierClickPort := modifierClickCmd.Int("port", 8989, "Daemon port")
|
||||
|
||||
// Note: Touch operations flags will be added when the functionality is implemented
|
||||
// touchTapTabID := touchTapCmd.String("tab", "", "Tab ID to perform touch tap on (optional, uses current tab if not specified)")
|
||||
// ... (other touch operation flags)
|
||||
|
||||
// Check if a subcommand is provided
|
||||
if len(os.Args) < 2 {
|
||||
printUsage()
|
||||
@@ -622,6 +746,163 @@ func main() {
|
||||
|
||||
fmt.Println("Storage cleared successfully")
|
||||
|
||||
case "drag-and-drop":
|
||||
dragAndDropCmd.Parse(os.Args[2:])
|
||||
|
||||
// Validate required parameters
|
||||
if *dragAndDropSource == "" {
|
||||
fmt.Fprintf(os.Stderr, "Error: --source parameter is required\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
if *dragAndDropTarget == "" {
|
||||
fmt.Fprintf(os.Stderr, "Error: --target parameter is required\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Create a client
|
||||
c := client.NewClient(*dragAndDropHost, *dragAndDropPort)
|
||||
|
||||
// Perform drag and drop
|
||||
err := c.DragAndDrop(*dragAndDropTabID, *dragAndDropSource, *dragAndDropTarget, *dragAndDropTimeout)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("Drag and drop completed successfully")
|
||||
|
||||
case "drag-and-drop-coordinates":
|
||||
dragAndDropCoordinatesCmd.Parse(os.Args[2:])
|
||||
|
||||
// Validate required parameters
|
||||
if *dragAndDropCoordinatesSource == "" {
|
||||
fmt.Fprintf(os.Stderr, "Error: --source parameter is required\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Create a client
|
||||
c := client.NewClient(*dragAndDropCoordinatesHost, *dragAndDropCoordinatesPort)
|
||||
|
||||
// Perform drag and drop to coordinates
|
||||
err := c.DragAndDropToCoordinates(*dragAndDropCoordinatesTabID, *dragAndDropCoordinatesSource, *dragAndDropCoordinatesX, *dragAndDropCoordinatesY, *dragAndDropCoordinatesTimeout)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Drag and drop to coordinates (%d, %d) completed successfully\n", *dragAndDropCoordinatesX, *dragAndDropCoordinatesY)
|
||||
|
||||
case "drag-and-drop-offset":
|
||||
dragAndDropOffsetCmd.Parse(os.Args[2:])
|
||||
|
||||
// Validate required parameters
|
||||
if *dragAndDropOffsetSource == "" {
|
||||
fmt.Fprintf(os.Stderr, "Error: --source parameter is required\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Create a client
|
||||
c := client.NewClient(*dragAndDropOffsetHost, *dragAndDropOffsetPort)
|
||||
|
||||
// Perform drag and drop by offset
|
||||
err := c.DragAndDropByOffset(*dragAndDropOffsetTabID, *dragAndDropOffsetSource, *dragAndDropOffsetX, *dragAndDropOffsetY, *dragAndDropOffsetTimeout)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Drag and drop by offset (%d, %d) completed successfully\n", *dragAndDropOffsetX, *dragAndDropOffsetY)
|
||||
|
||||
case "right-click":
|
||||
rightClickCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*rightClickHost, *rightClickPort)
|
||||
err := c.RightClick(*rightClickTabID, *rightClickSelector, *rightClickTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Right-click completed successfully\n")
|
||||
|
||||
case "double-click":
|
||||
doubleClickCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*doubleClickHost, *doubleClickPort)
|
||||
err := c.DoubleClick(*doubleClickTabID, *doubleClickSelector, *doubleClickTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Double-click completed successfully\n")
|
||||
|
||||
case "middle-click":
|
||||
middleClickCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*middleClickHost, *middleClickPort)
|
||||
err := c.MiddleClick(*middleClickTabID, *middleClickSelector, *middleClickTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Middle-click completed successfully\n")
|
||||
|
||||
case "hover":
|
||||
hoverCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*hoverHost, *hoverPort)
|
||||
err := c.Hover(*hoverTabID, *hoverSelector, *hoverTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Hover completed successfully\n")
|
||||
|
||||
case "mouse-move":
|
||||
mouseMoveCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*mouseMoveHost, *mouseMovePort)
|
||||
err := c.MouseMove(*mouseMoveTabID, *mouseMoveX, *mouseMoveY, *mouseMoveTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Mouse move to (%d, %d) completed successfully\n", *mouseMoveX, *mouseMoveY)
|
||||
|
||||
case "scroll-wheel":
|
||||
scrollWheelCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*scrollWheelHost, *scrollWheelPort)
|
||||
err := c.ScrollWheel(*scrollWheelTabID, *scrollWheelX, *scrollWheelY, *scrollWheelDeltaX, *scrollWheelDeltaY, *scrollWheelTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Scroll wheel at (%d, %d) with delta (%d, %d) completed successfully\n", *scrollWheelX, *scrollWheelY, *scrollWheelDeltaX, *scrollWheelDeltaY)
|
||||
|
||||
case "key-combination":
|
||||
keyCombinationCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*keyCombinationHost, *keyCombinationPort)
|
||||
err := c.KeyCombination(*keyCombinationTabID, *keyCombinationKeys, *keyCombinationTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Key combination '%s' sent successfully\n", *keyCombinationKeys)
|
||||
|
||||
case "special-key":
|
||||
specialKeyCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*specialKeyHost, *specialKeyPort)
|
||||
err := c.SpecialKey(*specialKeyTabID, *specialKeyKey, *specialKeyTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Special key '%s' sent successfully\n", *specialKeyKey)
|
||||
|
||||
case "modifier-click":
|
||||
modifierClickCmd.Parse(os.Args[2:])
|
||||
c := client.NewClient(*modifierClickHost, *modifierClickPort)
|
||||
err := c.ModifierClick(*modifierClickTabID, *modifierClickSelector, *modifierClickModifiers, *modifierClickTimeout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Modifier click with '%s' completed successfully\n", *modifierClickModifiers)
|
||||
|
||||
default:
|
||||
printUsage()
|
||||
os.Exit(1)
|
||||
@@ -653,6 +934,18 @@ func printUsage() {
|
||||
fmt.Println(" clear-all-site-data Clear all site data (cookies, storage, cache, etc.)")
|
||||
fmt.Println(" clear-cookies Clear cookies for a tab")
|
||||
fmt.Println(" clear-storage Clear web storage (localStorage, sessionStorage, etc.)")
|
||||
fmt.Println(" drag-and-drop Drag and drop from source element to target element")
|
||||
fmt.Println(" drag-and-drop-coordinates Drag and drop from source element to specific coordinates")
|
||||
fmt.Println(" drag-and-drop-offset Drag and drop from source element by relative offset")
|
||||
fmt.Println(" right-click Right-click on an element")
|
||||
fmt.Println(" double-click Double-click on an element")
|
||||
fmt.Println(" middle-click Middle-click on an element")
|
||||
fmt.Println(" hover Hover over an element")
|
||||
fmt.Println(" mouse-move Move mouse to specific coordinates")
|
||||
fmt.Println(" scroll-wheel Scroll with mouse wheel at specific coordinates")
|
||||
fmt.Println(" key-combination Send key combinations (Ctrl+C, Alt+Tab, etc.)")
|
||||
fmt.Println(" special-key Send special keys (Enter, Escape, Tab, F1, etc.)")
|
||||
fmt.Println(" modifier-click Click with modifier keys (Ctrl+click, Shift+click)")
|
||||
fmt.Println(" status Check if the daemon is running")
|
||||
fmt.Println("\nRun 'cremote <command> -h' for more information on a command")
|
||||
fmt.Println("\nBefore using this tool, make sure the daemon is running:")
|
||||
|
||||
Reference in new issue
Block a user