File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ Print to stdout instead (e.g. for piping):
3030pyobfuscate -i your_file.py --stdout
3131```
3232
33+ Print the installed version (from ` python_obfuscator.version ` ):
34+
35+ ```
36+ pyobfuscate --version
37+ ```
38+
3339## More Detailed Documentation
3440
3541You can use this as a module if you want
Original file line number Diff line number Diff line change 1+ import sys
12from pathlib import Path
23from typing import Annotated
34
45import typer
56
67import python_obfuscator
78from python_obfuscator .techniques import one_liner as one_liner_technique
9+ from python_obfuscator .version import __version__
810
911DEFAULT_OUTPUT_DIR = "obfuscated"
1012
@@ -25,6 +27,7 @@ def main(
2527 input_path : Annotated [
2628 Path ,
2729 typer .Option (
30+ ...,
2831 "--input" ,
2932 "-i" ,
3033 help = "File to obfuscate" ,
@@ -49,21 +52,26 @@ def main(
4952 ),
5053 ] = False ,
5154) -> None :
55+ resolved = input_path .expanduser ().resolve ()
56+
5257 obfuscate = python_obfuscator .obfuscator ()
5358 remove = []
5459 if not include_one_liner :
5560 remove .append (one_liner_technique )
5661
57- data = input_path .read_text ()
62+ data = resolved .read_text ()
5863 obfuscated_data = obfuscate .obfuscate (data , remove_techniques = remove )
5964
6065 if stdout :
6166 typer .echo (obfuscated_data )
6267 else :
63- out_path = _resolved_output_path (input_path )
68+ out_path = _resolved_output_path (resolved )
6469 out_path .write_text (obfuscated_data )
6570 typer .secho (f"Wrote { out_path } " , err = True )
6671
6772
6873def cli () -> None :
74+ if len (sys .argv ) == 2 and sys .argv [1 ] in ("--version" , "-V" ):
75+ typer .echo (__version__ )
76+ raise SystemExit (0 )
6977 typer .run (main )
You can’t perform that action at this time.
0 commit comments