Skip to content

Commit

Permalink
refactor(cli.ls): move definition order
Browse files Browse the repository at this point in the history
  • Loading branch information
loqusion committed Apr 21, 2024
1 parent 95c7f75 commit 88efd0f
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/hyprshade/cli/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@
from .utils import ls_dirs


@click.command(short_help="List available screen shaders")
@click.option("-l", "--long", is_flag=True, help="Long listing format")
def ls(long: bool):
"""List available screen shaders."""

shaders = ShaderWithMeta.get_shaders_list()
if not shaders:
return
width = max(map(len, map(str, shaders))) + 1

for shader in shaders:
c = "*" if shader.is_current else " "
if long:
click.echo(f"{c} {shader!s:{width}} {shader.path()}")
continue
if shader.is_current and not shader.is_in_shader_paths:
click.echo(f"{c} {shader!s} ({shader.path()})")
continue
click.echo(f"{c} {shader!s}")


@final
class ShaderWithMeta(PureShader):
_is_current: bool
Expand Down Expand Up @@ -65,24 +86,3 @@ def _bisect(a: list[ShaderWithMeta], x: ShaderWithMeta) -> int:
if y == x:
return i
return first_index


@click.command(short_help="List available screen shaders")
@click.option("-l", "--long", is_flag=True, help="Long listing format")
def ls(long: bool):
"""List available screen shaders."""

shaders = ShaderWithMeta.get_shaders_list()
if not shaders:
return
width = max(map(len, map(str, shaders))) + 1

for shader in shaders:
c = "*" if shader.is_current else " "
if long:
click.echo(f"{c} {shader!s:{width}} {shader.path()}")
continue
if shader.is_current and not shader.is_in_shader_paths:
click.echo(f"{c} {shader!s} ({shader.path()})")
continue
click.echo(f"{c} {shader!s}")

0 comments on commit 88efd0f

Please sign in to comment.