Skip to content

Commit

Permalink
Merge pull request #5 from python-thread/dev
Browse files Browse the repository at this point in the history
Style: Ruff formatting
  • Loading branch information
caffeine-addictt authored Feb 4, 2024
2 parents 5f8802a + 77a02d0 commit 973b17e
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 128 deletions.
52 changes: 52 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
indent-width = 2

[format]
# Exclude commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

indent-style = "space"
line-ending = "lf"
quote-style = "single"
docstring-code-format = true


[lint]
# Avoid enforcing line-length violations (`E501`)
ignore = ["E501"]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"


# Ignore `E402` (import violations) in all `__init__.py` files, and in select subdirectories.
[lint.per-file-ignores]
"__init__.py" = ["E402", "F401"]
"**/__init__.py" = ["E402", "F401"]
"**/{tests,docs,tools}/*" = ["E402"]
8 changes: 4 additions & 4 deletions src/thread-cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
Copyright (c) 2020, thread.ngjx.org. All rights reserved.
"""

__version__ = "0.1.0"
__version__ = '0.1.0'
from .utils.logging import ColorLogger, logging

# Export Core
from .base import cli_base as app
from .process import process as process_cli

app.command(
name="process",
name='process',
no_args_is_help=True,
context_settings={"allow_extra_args": True},
context_settings={'allow_extra_args': True},
)(process_cli)


Expand All @@ -29,4 +29,4 @@


# Wildcard export
__all__ = ["app"]
__all__ = ['app']
55 changes: 23 additions & 32 deletions src/thread-cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

from . import __version__
from .utils import DebugOption, VerboseOption, QuietOption, verbose_args_processor

logger = logging.getLogger('base')


cli_base = typer.Typer(
no_args_is_help = True,
rich_markup_mode = 'rich',
context_settings = {
'help_option_names': ['-h', '--help', 'help']
}
no_args_is_help=True,
rich_markup_mode='rich',
context_settings={'help_option_names': ['-h', '--help', 'help']},
)


Expand All @@ -21,19 +20,19 @@ def version_callback(value: bool):
raise typer.Exit()


@cli_base.callback(invoke_without_command = True)
@cli_base.callback(invoke_without_command=True)
def callback(
version: bool = typer.Option(
None, '--version',
callback = version_callback,
help = 'Get the current installed version',
is_eager = True
None,
'--version',
callback=version_callback,
help='Get the current installed version',
is_eager=True,
),

debug: bool = DebugOption,
verbose: bool = VerboseOption,
quiet: bool = QuietOption
):
quiet: bool = QuietOption,
):
"""
[b]Thread CLI[/b]\b\n
[white]Use thread from the terminal![/white]
Expand All @@ -45,20 +44,17 @@ def callback(
verbose_args_processor(debug, verbose, quiet)



# Help and Others
@cli_base.command(rich_help_panel = 'Help and Others')
@cli_base.command(rich_help_panel='Help and Others')
def help():
"""Get [yellow]help[/yellow] from the community. :question:"""
typer.echo('Feel free to search for or ask questions here!')
try:
logger.info('Attempting to open in web browser...')

import webbrowser
webbrowser.open(
'https://github.com/python-thread/thread/issues',
new = 2
)

webbrowser.open('https://github.com/python-thread/thread/issues', new=2)
typer.echo('Opening in web browser!')

except Exception as e:
Expand All @@ -67,17 +63,16 @@ def help():
typer.echo('https://github.com/python-thread/thread/issues')



@cli_base.command(rich_help_panel = 'Help and Others')
@cli_base.command(rich_help_panel='Help and Others')
def docs():
"""View our [yellow]documentation.[/yellow] :book:"""
typer.echo('Thanks for using Thread, here is our documentation!')
try:
logger.info('Attempting to open in web browser...')
import webbrowser

webbrowser.open(
'https://github.com/python-thread/thread/blob/main/docs/command-line.md',
new = 2
'https://github.com/python-thread/thread/blob/main/docs/command-line.md', new=2
)
typer.echo('Opening in web browser!')

Expand All @@ -87,18 +82,15 @@ def docs():
typer.echo('https://github.com/python-thread/thread/blob/main/docs/command-line.md')



@cli_base.command(rich_help_panel = 'Help and Others')
@cli_base.command(rich_help_panel='Help and Others')
def report():
"""[yellow]Report[/yellow] an issue. :bug:"""
typer.echo('Sorry you run into an issue, report it here!')
try:
logger.info('Attempting to open in web browser...')
import webbrowser
webbrowser.open(
'https://github.com/python-thread/thread/issues',
new = 2
)

webbrowser.open('https://github.com/python-thread/thread/issues', new=2)
typer.echo('Opening in web browser!')

except Exception as e:
Expand All @@ -107,11 +99,10 @@ def report():
typer.echo('https://github.com/python-thread/thread/issues')



# Utils and Configs
@cli_base.command(rich_help_panel = 'Utils and Configs')
@cli_base.command(rich_help_panel='Utils and Configs')
def config(configuration: str):
"""
[blue]Configure[/blue] the system. :wrench:
"""
typer.echo('Coming soon!')
typer.echo('Coming soon!')
Loading

0 comments on commit 973b17e

Please sign in to comment.