Skip to content

Commit

Permalink
yapf git action, log -a feat
Browse files Browse the repository at this point in the history
  • Loading branch information
justjokiing committed Jan 7, 2025
1 parent c29b1f6 commit 3042560
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/yapf_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: YAPF Formatting Check
on: [push]
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: run YAPF to test if python code is correctly formatted
uses: AlexanderMelde/[email protected]
with:
args: --verbose
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "kshift"
version = "0.2.0"
version = "0.2.1"
authors = [
{ name="Seth Mackert", email="[email protected]" },
]
Expand Down
39 changes: 24 additions & 15 deletions src/kshift/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,22 @@ def config():


@cli.command(help="Tail on kshift logs")
def logs():
@click.option(
"-a",
"--all",
is_flag=True,
help="Print the entire log file",
)
def logs(all):

def tail(file, num_lines=10):
print(file)
with open(file, 'r') as f:
lines = f.readlines()
for line in lines[-num_lines:]:
print(line, end="")
print(f"Log @ {log_file}")
with open(log_file, 'r') as f:
lines = f.readlines()
if not all:
lines = lines[-10:]

tail(log_file)
for line in lines:
print(line, end="")


@cli.command(help="Change themes or apply specific theme elements")
Expand All @@ -299,9 +305,10 @@ def tail(file, num_lines=10):
default=None,
nargs=1,
metavar="[THEME_NAME]")
@click.option(
"--list", "list_themes", is_flag=True, help="List all available themes."
)
@click.option("--list",
"list_themes",
is_flag=True,
help="List all available themes.")
@click.option(
"-c",
"--colorscheme",
Expand All @@ -326,7 +333,8 @@ def tail(file, num_lines=10):
type=str,
help="Set a specific desktop theme (overrides theme)",
)
def theme(theme, list_themes, colorscheme, icontheme, wallpaper, desktop_theme):
def theme(theme, list_themes, colorscheme, icontheme, wallpaper,
desktop_theme):
"""Apply a theme or specific theme elements.
THEME_NAME is optional and can be passed as a positional argument.
Expand All @@ -335,8 +343,7 @@ def theme(theme, list_themes, colorscheme, icontheme, wallpaper, desktop_theme):
# Ensure `--list` is mutually exclusive with other options/arguments
if theme or any([colorscheme, icontheme, wallpaper, desktop_theme]):
raise click.UsageError(
"--list cannot be used with other options or arguments."
)
"--list cannot be used with other options or arguments.")
# List all available themes
print("Available themes:")
for name, theme_config in c.themes.items():
Expand Down Expand Up @@ -369,7 +376,9 @@ def theme(theme, list_themes, colorscheme, icontheme, wallpaper, desktop_theme):

# If there were no arguments
# Determine which theme should be active, then shift to it
if not any([theme, list_themes, colorscheme, icontheme, wallpaper, desktop_theme]):
if not any(
[theme, list_themes, colorscheme, icontheme, wallpaper, desktop_theme
]):

themes = []

Expand Down

0 comments on commit 3042560

Please sign in to comment.