From be785f37c1c442888dcb412c277ccc99c0a3f835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=A3=E6=A9=99?= <68316902+laorange@users.noreply.github.com> Date: Tue, 13 Dec 2022 18:42:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20-v=20=E6=9F=A5=E7=9C=8B=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 5 +++-- stoken/__init__.py | 3 +++ stoken/main.py | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 907a632..b9c762e 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,14 @@ from setuptools import setup, find_packages - from pathlib import Path +from stoken import version + HERE = Path(__file__).parent README = (HERE / "README.md").read_text(encoding="utf-8") setup( name="stoken", - version="0.2.1", + version=version, keywords=["git", "data desensitization", "replace token"], description="A code desensitization tool, which can substitute tokens (and other sensitive information) in your code.", long_description=README, diff --git a/stoken/__init__.py b/stoken/__init__.py index e69de29..b4b525b 100644 --- a/stoken/__init__.py +++ b/stoken/__init__.py @@ -0,0 +1,3 @@ +from stoken.main import Stoken, VERSION, Config + +version = VERSION diff --git a/stoken/main.py b/stoken/main.py index 6d6f604..6aa7913 100644 --- a/stoken/main.py +++ b/stoken/main.py @@ -9,6 +9,7 @@ import click import git +VERSION = "0.2.2" README_URL = "https://github.com/laorange/stoken" BASE_DIR = Path.cwd().resolve() colorama.just_fix_windows_console() @@ -144,7 +145,11 @@ def execute(self, path: Path = None): @click.option("-s", "--variable-suffix", default="}}#", help="The suffix of variable placeholder. Default: }}#") @click.option('--debug', is_flag=True, help="In debug mode, `stoken` won't modify files, only detect tokens.") @click.option('--no-git', is_flag=True, help="By default, the program will detect if there is a git directory, and if so, it will ignore the files in .gitignore. Activate this option to detect all the files.") -def main(mode: str, encoding: str, variable_prefix: str, variable_suffix: str, debug: bool, no_git: bool): +@click.option("-v", "--version", is_flag=True, help="To get the current version of stoken.") +def main(mode: str, encoding: str, variable_prefix: str, variable_suffix: str, debug: bool, no_git: bool, version: bool): + if version: + return print(f"v{VERSION}") + stoken = Stoken(mode, encoding, variable_prefix, variable_suffix, debug, no_git) stoken.execute() stoken.quit_with_info(f"{Fore.GREEN}stoken: finished!{Fore.RESET}")