add --left/--right commands into move and add shorter aliases to move flags
This commit is contained in:
@@ -159,12 +159,14 @@ def group_add_tab(group, url):
|
|||||||
|
|
||||||
@group_group.command("move")
|
@group_group.command("move")
|
||||||
@click.argument("group")
|
@click.argument("group")
|
||||||
@click.option("--forward", is_flag=True, help="Move group one position to the right")
|
@click.option("-f", "--forward", "forward", is_flag=True, help="Move group one position to the right")
|
||||||
@click.option("--backward", is_flag=True, help="Move group one position to the left")
|
@click.option("-b", "--backward", "backward", is_flag=True, help="Move group one position to the left")
|
||||||
|
@click.option("-r", "--right", "forward", is_flag=True, help="Move group one position to the right")
|
||||||
|
@click.option("-l", "--left", "backward", is_flag=True, help="Move group one position to the left")
|
||||||
def group_move(group, forward, backward):
|
def group_move(group, forward, backward):
|
||||||
"""Move a tab group forward or backward (name or ID)."""
|
"""Move a tab group forward/backward or right/left (name or ID)."""
|
||||||
if not forward and not backward:
|
if not forward and not backward:
|
||||||
console.print("[red]Specify --forward or --backward[/red]")
|
console.print("[red]Specify --forward/--right or --backward/--left[/red]")
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
result = _handle("group.move", {"group": group, "forward": forward, "backward": backward})
|
result = _handle("group.move", {"group": group, "forward": forward, "backward": backward})
|
||||||
if isinstance(result, dict) and not result.get("moved"):
|
if isinstance(result, dict) and not result.get("moved"):
|
||||||
|
|||||||
@@ -98,13 +98,15 @@ def tabs_close(tab_id, inactive, duplicates):
|
|||||||
|
|
||||||
@tabs_group.command("move")
|
@tabs_group.command("move")
|
||||||
@click.argument("tab_id", type=int)
|
@click.argument("tab_id", type=int)
|
||||||
@click.option("--forward", is_flag=True, help="Move one position to the right")
|
@click.option("-f", "--forward", "forward", is_flag=True, help="Move one position to the right")
|
||||||
@click.option("--backward", is_flag=True, help="Move one position to the left")
|
@click.option("-b", "--backward", "backward", is_flag=True, help="Move one position to the left")
|
||||||
|
@click.option("-r", "--right", "forward", is_flag=True, help="Move one position to the right")
|
||||||
|
@click.option("-l", "--left", "backward", is_flag=True, help="Move one position to the left")
|
||||||
@click.option("--group", "group_id", type=int, default=None, help="Move to tab group ID")
|
@click.option("--group", "group_id", type=int, default=None, help="Move to tab group ID")
|
||||||
@click.option("--window", "window_id", type=int, default=None, help="Move to window ID")
|
@click.option("--window", "window_id", type=int, default=None, help="Move to window ID")
|
||||||
@click.option("--index", type=int, default=None, help="Absolute position index in target")
|
@click.option("--index", type=int, default=None, help="Absolute position index in target")
|
||||||
def tabs_move(tab_id, forward, backward, group_id, window_id, index):
|
def tabs_move(tab_id, forward, backward, group_id, window_id, index):
|
||||||
"""Move a tab. Use --forward/--backward for relative movement."""
|
"""Move a tab. Use --forward/--backward or --right/--left for relative movement."""
|
||||||
_handle("tabs.move", {
|
_handle("tabs.move", {
|
||||||
"tabId": tab_id, "forward": forward, "backward": backward,
|
"tabId": tab_id, "forward": forward, "backward": backward,
|
||||||
"groupId": group_id, "windowId": window_id, "index": index,
|
"groupId": group_id, "windowId": window_id, "index": index,
|
||||||
|
|||||||
@@ -205,6 +205,29 @@ def test_group_list_leaves_unnamed_group_cell_empty():
|
|||||||
assert "grey" in result.output
|
assert "grey" in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_tabs_move_accepts_right_short_alias():
|
||||||
|
with patch("browser_cli.commands.tabs.send_command") as send_command:
|
||||||
|
result = CliRunner().invoke(main, ["tabs", "move", "12", "-r"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
send_command.assert_called_once_with(
|
||||||
|
"tabs.move",
|
||||||
|
{"tabId": 12, "forward": True, "backward": False, "groupId": None, "windowId": None, "index": None},
|
||||||
|
profile=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_groups_move_accepts_left_short_alias():
|
||||||
|
with patch("browser_cli.commands.groups.send_command") as send_command:
|
||||||
|
result = CliRunner().invoke(main, ["groups", "move", "research", "-l"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
send_command.assert_called_once_with(
|
||||||
|
"group.move", {"group": "research", "forward": False, "backward": True}, profile=None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_windows_list_multi_browser_shows_browser_column():
|
def test_windows_list_multi_browser_shows_browser_column():
|
||||||
def fake_send_command(command, args=None, profile=None):
|
def fake_send_command(command, args=None, profile=None):
|
||||||
assert command == "windows.list"
|
assert command == "windows.list"
|
||||||
|
|||||||
Reference in New Issue
Block a user