mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-08 12:56:45 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@@ -145,7 +145,7 @@ jobs:
|
|||||||
run: |-
|
run: |-
|
||||||
current_version=$(hatch version)
|
current_version=$(hatch version)
|
||||||
PYAPP_PROJECT_PATH="${{ github.workspace }}/dist/isponsorblocktv-${current_version}-py3-none-any.whl" hatch -v build -t binary
|
PYAPP_PROJECT_PATH="${{ github.workspace }}/dist/isponsorblocktv-${current_version}-py3-none-any.whl" hatch -v build -t binary
|
||||||
|
|
||||||
- name: Rename binary
|
- name: Rename binary
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
run: |-
|
run: |-
|
||||||
@@ -164,7 +164,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
||||||
# only run step if the event is a published release
|
# only run step if the event is a published release
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
if: github.event_name == 'release' && github.event.action == 'published'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Get artifact
|
- name: Get artifact
|
||||||
@@ -179,10 +179,10 @@ jobs:
|
|||||||
|
|
||||||
|
|
||||||
publish-to-release:
|
publish-to-release:
|
||||||
needs:
|
needs:
|
||||||
- build-sdist-and-wheel
|
- build-sdist-and-wheel
|
||||||
- build-binaries
|
- build-binaries
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
if: github.event_name == 'release' && github.event.action == 'published'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
@@ -193,4 +193,4 @@ jobs:
|
|||||||
- name: Add assets to release
|
- name: Add assets to release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: dist/*
|
files: dist/*
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ ssdp==1.3.0
|
|||||||
textual==0.58.0
|
textual==0.58.0
|
||||||
textual-slider==0.1.1
|
textual-slider==0.1.1
|
||||||
xmltodict==0.13.0
|
xmltodict==0.13.0
|
||||||
rich_click==1.8.3
|
rich_click==1.8.3
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import rich_click as click
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import rich_click as click
|
||||||
from appdirs import user_data_dir
|
from appdirs import user_data_dir
|
||||||
|
|
||||||
from . import config_setup, main, setup_wizard
|
from . import config_setup, main, setup_wizard
|
||||||
@@ -127,17 +127,30 @@ class Config:
|
|||||||
|
|
||||||
|
|
||||||
@click.group(invoke_without_command=True)
|
@click.group(invoke_without_command=True)
|
||||||
@click.option('--data', '-d', default=lambda: os.getenv("iSPBTV_data_dir") or user_data_dir("iSponsorBlockTV", "dmunozv04"), help='data directory')
|
@click.option(
|
||||||
@click.option('--debug', is_flag=True, help='debug mode')
|
"--data",
|
||||||
#legacy commands as arguments
|
"-d",
|
||||||
@click.option('--setup', is_flag=True, help='Setup the program graphically', hidden=True)
|
default=lambda: os.getenv("iSPBTV_data_dir")
|
||||||
@click.option('--setup-cli', is_flag=True, help='Setup the program in the command line', hidden=True)
|
or user_data_dir("iSponsorBlockTV", "dmunozv04"),
|
||||||
|
help="data directory",
|
||||||
|
)
|
||||||
|
@click.option("--debug", is_flag=True, help="debug mode")
|
||||||
|
# legacy commands as arguments
|
||||||
|
@click.option(
|
||||||
|
"--setup", is_flag=True, help="Setup the program graphically", hidden=True
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
"--setup-cli",
|
||||||
|
is_flag=True,
|
||||||
|
help="Setup the program in the command line",
|
||||||
|
hidden=True,
|
||||||
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, data, debug, setup, setup_cli):
|
def cli(ctx, data, debug, setup, setup_cli):
|
||||||
"""iSponsorblockTV"""
|
"""iSponsorblockTV"""
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
ctx.obj['data_dir'] = data
|
ctx.obj["data_dir"] = data
|
||||||
ctx.obj['debug'] = debug
|
ctx.obj["debug"] = debug
|
||||||
if debug:
|
if debug:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
if ctx.invoked_subcommand is None:
|
if ctx.invoked_subcommand is None:
|
||||||
@@ -148,37 +161,58 @@ def cli(ctx, data, debug, setup, setup_cli):
|
|||||||
else:
|
else:
|
||||||
ctx.invoke(start)
|
ctx.invoke(start)
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def setup(ctx):
|
def setup(ctx):
|
||||||
"""Setup the program graphically"""
|
"""Setup the program graphically"""
|
||||||
config = Config(ctx.obj['data_dir'])
|
config = Config(ctx.obj["data_dir"])
|
||||||
setup_wizard.main(config)
|
setup_wizard.main(config)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
setup_command = setup
|
setup_command = setup
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def setup_cli(ctx):
|
def setup_cli(ctx):
|
||||||
"""Setup the program in the command line"""
|
"""Setup the program in the command line"""
|
||||||
config = Config(ctx.obj['data_dir'])
|
config = Config(ctx.obj["data_dir"])
|
||||||
config_setup.main(config, ctx.obj['debug'])
|
config_setup.main(config, ctx.obj["debug"])
|
||||||
|
|
||||||
|
|
||||||
setup_cli_command = setup_cli
|
setup_cli_command = setup_cli
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def start(ctx):
|
def start(ctx):
|
||||||
"""Start the main program"""
|
"""Start the main program"""
|
||||||
config = Config(ctx.obj['data_dir'])
|
config = Config(ctx.obj["data_dir"])
|
||||||
config.validate()
|
config.validate()
|
||||||
main.main(config, ctx.obj['debug'])
|
main.main(config, ctx.obj["debug"])
|
||||||
|
|
||||||
|
|
||||||
# Create fake "self" group to show pyapp options in help menu
|
# Create fake "self" group to show pyapp options in help menu
|
||||||
#Subcommands remove, restore, update
|
# Subcommands remove, restore, update
|
||||||
pyapp_group = click.RichGroup("self", help="pyapp options (update, remove, restore)")
|
pyapp_group = click.RichGroup("self", help="pyapp options (update, remove, restore)")
|
||||||
pyapp_group.add_command(click.RichCommand("update", help="Update the package to the latest version"))
|
pyapp_group.add_command(
|
||||||
pyapp_group.add_command(click.Command("remove", help="Remove the package, wiping the installation but not the data"))
|
click.RichCommand("update", help="Update the package to the latest version")
|
||||||
pyapp_group.add_command(click.RichCommand("restore", help="Restore the package to its original state by reinstalling it"))
|
)
|
||||||
|
pyapp_group.add_command(
|
||||||
|
click.Command(
|
||||||
|
"remove", help="Remove the package, wiping the installation but not the data"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
pyapp_group.add_command(
|
||||||
|
click.RichCommand(
|
||||||
|
"restore", help="Restore the package to its original state by reinstalling it"
|
||||||
|
)
|
||||||
|
)
|
||||||
if os.getenv("PYAPP"):
|
if os.getenv("PYAPP"):
|
||||||
cli.add_command(pyapp_group)
|
cli.add_command(pyapp_group)
|
||||||
|
|
||||||
|
|
||||||
def app_start():
|
def app_start():
|
||||||
cli(obj={})
|
cli(obj={})
|
||||||
|
|||||||
Reference in New Issue
Block a user