standardize arguments
This commit is contained in:
parent
1651c4312e
commit
6bad614f9e
|
@ -616,7 +616,8 @@ func (c *Client) SwitchToIframe(tabID, selector string, timeout int) error {
|
||||||
|
|
||||||
// SwitchToMain switches the context back to the main page
|
// SwitchToMain switches the context back to the main page
|
||||||
// If tabID is empty, the current tab will be used
|
// If tabID is empty, the current tab will be used
|
||||||
func (c *Client) SwitchToMain(tabID string) error {
|
// timeout is in seconds, 0 means no timeout
|
||||||
|
func (c *Client) SwitchToMain(tabID string, timeout int) error {
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
|
|
||||||
// Only include tab ID if it's provided
|
// Only include tab ID if it's provided
|
||||||
|
@ -624,6 +625,11 @@ func (c *Client) SwitchToMain(tabID string) error {
|
||||||
params["tab"] = tabID
|
params["tab"] = tabID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add timeout if specified
|
||||||
|
if timeout > 0 {
|
||||||
|
params["timeout"] = strconv.Itoa(timeout)
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := c.SendCommand("switch-main", params)
|
resp, err := c.SendCommand("switch-main", params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
3
main.go
3
main.go
|
@ -124,6 +124,7 @@ func main() {
|
||||||
|
|
||||||
// switch-main flags
|
// switch-main flags
|
||||||
switchMainTabID := switchMainCmd.String("tab", "", "Tab ID to switch back to main context (optional, uses current tab if not specified)")
|
switchMainTabID := switchMainCmd.String("tab", "", "Tab ID to switch back to main context (optional, uses current tab if not specified)")
|
||||||
|
switchMainTimeout := switchMainCmd.Int("timeout", 5, "Timeout in seconds for switching back to main context")
|
||||||
switchMainHost := switchMainCmd.String("host", "localhost", "Daemon host")
|
switchMainHost := switchMainCmd.String("host", "localhost", "Daemon host")
|
||||||
switchMainPort := switchMainCmd.Int("port", 8989, "Daemon port")
|
switchMainPort := switchMainCmd.Int("port", 8989, "Daemon port")
|
||||||
|
|
||||||
|
@ -412,7 +413,7 @@ func main() {
|
||||||
c := client.NewClient(*switchMainHost, *switchMainPort)
|
c := client.NewClient(*switchMainHost, *switchMainPort)
|
||||||
|
|
||||||
// Switch back to main page
|
// Switch back to main page
|
||||||
err := c.SwitchToMain(*switchMainTabID)
|
err := c.SwitchToMain(*switchMainTabID, *switchMainTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
Loading…
Reference in New Issue