-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from stepanzubkov/dev
Version 0.6.0: Config view, debug, url list
- Loading branch information
Showing
13 changed files
with
292 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
Command for working with user config | ||
""" | ||
import click | ||
|
||
import florgon_cc_cli.config | ||
from florgon_cc_cli.services.config import deserialize_config | ||
|
||
|
||
@click.group() | ||
def config(): | ||
""" | ||
Work with user config. | ||
""" | ||
|
||
|
||
@config.command() | ||
@click.option( | ||
"-r", "--raw", is_flag=True, default=False, help="Prints config 'as is', in toml format." | ||
) | ||
def show(raw: bool): | ||
""" | ||
Prints user config. | ||
""" | ||
if raw: | ||
with open(florgon_cc_cli.config.CONFIG_FILE, "r") as f: | ||
click.echo(f.read()) | ||
return | ||
|
||
user_config = deserialize_config() | ||
for key, value in user_config.items(): | ||
click.echo(click.style(f"{key:20}", fg="green") + f"{value}") | ||
|
||
|
||
@config.command() | ||
def show_path(): | ||
""" | ||
Prints path of config file. | ||
""" | ||
click.echo(str(florgon_cc_cli.config.CONFIG_FILE)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
""" | ||
Error model from CC API response. | ||
""" | ||
from typing import TypedDict | ||
|
||
|
||
class Error(TypedDict): | ||
message: str | ||
code: int | ||
status: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
Url TypedDict model from CC API responses. | ||
""" | ||
from typing import TypedDict, Optional | ||
|
||
|
||
class UrlLink(TypedDict): | ||
""" | ||
Single url link. | ||
""" | ||
|
||
href: str | ||
|
||
|
||
class UrlLinks(TypedDict): | ||
""" | ||
Url links in url field `_links`. | ||
""" | ||
|
||
qr: UrlLink | ||
stats: Optional[UrlLink] | ||
|
||
|
||
class Url(TypedDict): | ||
""" | ||
Url model from API. | ||
""" | ||
|
||
id: int | ||
redirect_url: str | ||
hash: str | ||
expires_at: float | ||
is_expired: bool | ||
stats_is_public: bool | ||
is_deleted: bool | ||
_links: UrlLinks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
click | ||
pick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.