Verified Commit ddc903cc authored by Adrian DC's avatar Adrian DC
Browse files

feat(git_dashboard_panel): create '--current' mode and 'dc' alias

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 4bf49c20
Loading
Loading
Loading
Loading
+2
Changes for profiles/gitconfig/alias/interfaces/dc.alias: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Dashboard panel of current folder Git paths
dct-tools-git-dashboard-panel --current
+33 −9
Changes for src/tools/git_dashboard_panel.py: 33 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ def provide_fzf_preview(configuration: str, ) -> str:

# Provide fzf reload command
def provide_fzf_reload(
    presets: bool,
    configuration: str,
    depth: int,
    discover: bool,
@@ -120,6 +121,17 @@ def provide_fzf_reload(

    # Variables
    discover_block: str = ''
    presets_block: str = ''

    # Enable presets
    if presets:
        presets_block = f"""
            sed \
                -e 's|^~/|{environ.get("HOME", "")}/|' \
                -e 's/^$/{SEPARATOR_SHORT}/' \
                '{configuration}';
            echo '{SEPARATOR_LONG}';
        """

    # Enable discovery
    if discover:
@@ -138,19 +150,16 @@ def provide_fzf_reload(
        echo '{LABEL_CONFIGURE}';
        echo '{LABEL_EXIT}';
        echo '{SEPARATOR_SHORT}';
        sed \
            -e 's|^~/|{environ.get("HOME", "")}/|' \
            -e 's/^$/{SEPARATOR_SHORT}/' \
            '{configuration}';
        echo '{SEPARATOR_LONG}';
        {presets_block}
        {discover_block}
    """

# Run fzf menu
def run_fzf(
    configuration: str,
    depth: int,
    presets: bool,
    discover: bool,
    depth: int,
) -> str:

    # Configure fzf
@@ -182,7 +191,7 @@ def run_fzf(
            '--bind',
            'enter:accept+abort',
            '--bind',
            f'start:reload-sync:{provide_fzf_reload(configuration, depth, discover)}',
            f'start:reload-sync:{provide_fzf_reload(presets, configuration, depth, discover)}',
            '--border',
            '--border-label',
            f' {Tools.NAME} ({Bundle.NAME}) ',
@@ -213,6 +222,7 @@ def run_fzf(

# Dashboard panel of Git paths, pylint: disable=duplicate-code
def git_dashboard_panel(
    presets: bool,
    discovery: bool,
    depth: int,
    editor: str,
@@ -250,8 +260,9 @@ def git_dashboard_panel(
        # Show menu
        selection = run_fzf(
            configuration=str(configuration),
            depth=depth,
            presets=presets,
            discover=discovery,
            depth=depth,
        )

        # Interrupt menu
@@ -295,6 +306,7 @@ def main() -> None:
    # Variables
    discovery: bool
    group: _ArgumentGroup
    presets: bool = True
    result: int

    # Configure tool
@@ -325,6 +337,12 @@ def main() -> None:
        action='store_true',
        help='Show this help message',
    )
    group.add_argument(
        '--current',
        dest='current',
        action='store_true',
        help='Show only current Git paths discovery',
    )
    group.add_argument(
        '--enable-discovery',
        dest='enable_discovery',
@@ -362,8 +380,13 @@ def main() -> None:
        Platform.flush()
        sys_exit(0)

    # Parse current
    if options.current:
        presets = False
        discovery = True

    # Parse discovery
    if options.disable_discovery:
    elif options.disable_discovery:
        discovery = False
    elif options.enable_discovery:
        discovery = True
@@ -384,6 +407,7 @@ def main() -> None:

    # Run tool
    result = git_dashboard_panel(
        presets=presets,
        discovery=discovery,
        depth=options.depth,
        editor=options.editor,