99
1010
1111def get_latest_version () -> Optional [str ]:
12+ """Fetches the latest version of the library from PyPI."""
1213 with _request .urlopen (URL ) as response :
1314 if response .status == 200 :
1415 data = _json .load (response )
@@ -18,6 +19,8 @@ def get_latest_version() -> Optional[str]:
1819
1920
2021def is_latest_version () -> Optional [bool ]:
22+ """Checks if the currently installed version of the
23+ library is the latest one available on PyPI."""
2124 try :
2225 if (latest := get_latest_version ()) in {"" , None }:
2326 return None
@@ -34,44 +37,52 @@ def is_latest_version() -> Optional[bool]:
3437CLI_COLORS = {
3538 "border" : "dim|br:black" ,
3639 "class" : "br:cyan" ,
40+ "cmd" : "green" ,
3741 "const" : "br:blue" ,
38- "func " : "br:green" ,
42+ "fn " : "br:green" ,
3943 "heading" : "br:white" ,
4044 "import" : "magenta" ,
4145 "lib" : "br:magenta" ,
42- "link" : "u| br:blue" ,
46+ "link" : "br:blue" ,
4347 "notice" : "br:yellow" ,
4448 "punctuator" : "br:black" ,
4549 "text" : "white" ,
4650}
4751CLI_HELP = FormatCodes .to_ansi (
48- rf""" [_|b|#7075FF] __ __
52+ rf"""[_]
53+ [b|#7075FF] __ __
4954 [b|#7075FF] _ __ __ __/ / / /_ __ ___ __
5055 [b|#7075FF] | |/ // / / / / / __ \/ / / | |/ /
5156 [b|#7075FF] > , </ /_/ / /_/ /_/ / /_/ /> , <
5257 [b|#7075FF]/_/|_|\____/\__/\____/\____//_/|_| [*|#000|BG:#8085FF] v[b]{ __version__ } [*|dim|{ CLI_COLORS ["notice" ]} ]({ "" if IS_LATEST_VERSION else " (newer available)" } )[*]
5358
54- [i|#9095FF]A TON OF COOL FUNCTIONS, YOU NEED ![*]
59+ [i|#9095FF]Simplify common programming tasks ![*]
5560
61+ [b|{ CLI_COLORS ["heading" ]} ](Commands:)[*]
62+ [{ CLI_COLORS ["border" ]} ](╭───────────────────────────────────────────────────╮)[*]
63+ [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["cmd" ]} ]xulbux-lib[*] [{ CLI_COLORS ["text" ]} ]Show library info and usage[*] [{ CLI_COLORS ["border" ]} ](│)[*]
64+ [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["cmd" ]} ]xulbux-lib [b|{ CLI_COLORS ["fn" ]} ](fc) [{ CLI_COLORS ["text" ]} ]Render a string's format codes[*] [{ CLI_COLORS ["border" ]} ](│)[*]
65+ [{ CLI_COLORS ["border" ]} ](╰───────────────────────────────────────────────────╯)[*]
5666 [b|{ CLI_COLORS ["heading" ]} ](Usage:)[*]
5767 [{ CLI_COLORS ["border" ]} ](╭───────────────────────────────────────────────────╮)[*]
5868 [{ CLI_COLORS ["border" ]} ](│) [i|{ CLI_COLORS ["punctuator" ]} ](# LIBRARY CONSTANTS)[*] [{ CLI_COLORS ["border" ]} ](│)[*]
5969 [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["import" ]} ]from [{ CLI_COLORS ["lib" ]} ]xulbux[{ CLI_COLORS ["punctuator" ]} ].[{ CLI_COLORS ["lib" ]} ]base[{ CLI_COLORS ["punctuator" ]} ].[{ CLI_COLORS ["lib" ]} ]consts [{ CLI_COLORS ["import" ]} ]import [{ CLI_COLORS ["const" ]} ]COLOR[{ CLI_COLORS ["punctuator" ]} ], [{ CLI_COLORS ["const" ]} ]CHARS[{ CLI_COLORS ["punctuator" ]} ], [{ CLI_COLORS ["const" ]} ]ANSI[*] [{ CLI_COLORS ["border" ]} ](│)[*]
6070 [{ CLI_COLORS ["border" ]} ](│) [i|{ CLI_COLORS ["punctuator" ]} ](# Main Classes)[*] [{ CLI_COLORS ["border" ]} ](│)[*]
6171 [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["import" ]} ]from [{ CLI_COLORS ["lib" ]} ]xulbux [{ CLI_COLORS ["import" ]} ]import [{ CLI_COLORS ["class" ]} ]Code[{ CLI_COLORS ["punctuator" ]} ], [{ CLI_COLORS ["class" ]} ]Color[{ CLI_COLORS ["punctuator" ]} ], [{ CLI_COLORS ["class" ]} ]Console[{ CLI_COLORS ["punctuator" ]} ], ...[*] [{ CLI_COLORS ["border" ]} ](│)[*]
6272 [{ CLI_COLORS ["border" ]} ](│) [i|{ CLI_COLORS ["punctuator" ]} ](# module specific imports)[*] [{ CLI_COLORS ["border" ]} ](│)[*]
63- [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["import" ]} ]from [{ CLI_COLORS ["lib" ]} ]xulbux[{ CLI_COLORS ["punctuator" ]} ].[{ CLI_COLORS ["lib" ]} ]color [{ CLI_COLORS ["import" ]} ]import [{ CLI_COLORS ["func " ]} ]rgba[{ CLI_COLORS ["punctuator" ]} ], [{ CLI_COLORS ["func " ]} ]hsla[{ CLI_COLORS ["punctuator" ]} ], [{ CLI_COLORS ["func " ]} ]hexa[*] [{ CLI_COLORS ["border" ]} ](│)
73+ [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["import" ]} ]from [{ CLI_COLORS ["lib" ]} ]xulbux[{ CLI_COLORS ["punctuator" ]} ].[{ CLI_COLORS ["lib" ]} ]color [{ CLI_COLORS ["import" ]} ]import [{ CLI_COLORS ["fn " ]} ]rgba[{ CLI_COLORS ["punctuator" ]} ], [{ CLI_COLORS ["fn " ]} ]hsla[{ CLI_COLORS ["punctuator" ]} ], [{ CLI_COLORS ["fn " ]} ]hexa[*] [{ CLI_COLORS ["border" ]} ](│)
6474 [{ CLI_COLORS ["border" ]} ](╰───────────────────────────────────────────────────╯)[*]
6575 [b|{ CLI_COLORS ["heading" ]} ](Documentation:)[*]
6676 [{ CLI_COLORS ["border" ]} ](╭───────────────────────────────────────────────────╮)[*]
67- [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["text" ]} ]For more information see the GitHub page. [{ CLI_COLORS ["border" ]} ](│)[*]
68- [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["link" ]} ]( https://github.com/xulbux/python-lib-xulbux/wiki) [{ CLI_COLORS ["border" ]} ](│)[*]
77+ [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["text" ]} ]For more information see the GitHub wiki page: [{ CLI_COLORS ["border" ]} ](│)[*]
78+ [{ CLI_COLORS ["border" ]} ](│) [{ CLI_COLORS ["link" ]} |link: https://github.com/xulbux/python-lib-xulbux/wiki](github.com/xulbux/python-lib-xulbux/wiki) [{ CLI_COLORS ["border" ]} ](│)[*]
6979 [{ CLI_COLORS ["border" ]} ](╰───────────────────────────────────────────────────╯)[*]
7080 [_]"""
7181)
7282
7383
7484def show_help () -> None :
85+ """CLI command function for `xulbux-lib` command, which shows some information about the library."""
7586 FormatCodes ._config_console ()
7687 print (CLI_HELP )
7788 Console .pause_exit (" [dim](Press any key to exit...)\n \n " , pause = True )
0 commit comments