Skip to content

Commit

Permalink
CLI (#220)
Browse files Browse the repository at this point in the history
* fix :  entry_points added #211

* doc : CHANGELOG updated #211

* doc : README updated #211

* fix : test.yml updated #211

* fix : help_func function modified #211

* doc : CHANGELOG updated #211

* fix : help_func function modified #211

* fix : unused import removed

* fix : tests updated #211

* fix : autopep8

* doc : help section modified
  • Loading branch information
sepandhaghighi authored Mar 5, 2023
1 parent 0870f9c commit cf7f6ed
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 28 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
- name: First test
run: |
python setup.py install
python -m art test
python -m art test2
art
art test
art test2
- name: Install dev-requirements
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- Test system modified
- `README.md` modified
- `help_func` function modified
- CLI mode updated
## [5.8] - 2022-11-23
### Added
- 8 new font
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -734,21 +734,23 @@ _/ _ _ _/
### Testing
- Only ASCII fonts and arts :
```
python -m art test
art test
```

- All fonts, arts and decorations :
```
python -m art test2
art test2
```

### CLI
- List of arts : `python -m art list` or `python -m art arts`
- List of fonts : `python -m art fonts`
- Text : `python -m art text yourtext fontname(optional)`
- Art : `python -m art shape art_name` or `python -m art art art_name`
- Save : `python -m art save yourtext fontname(optional)`
- All : `python -m art all yourtext`
### CLI
⚠️ You can use `art` or `python -m art` to run this mode

- List of arts : `art list` or `art arts`
- List of fonts : `art fonts`
- Text : `art text [yourtext] [fontname(optional)]`
- Art : `art shape [artname]` or `art art [artname]`
- Save : `art save [yourtext] [fontname(optional)]`
- All : `art all [yourtext]`

### Telegram bot

Expand Down
11 changes: 10 additions & 1 deletion art/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ def select_test(test_name="TEST"):
sys.exit(error_flag)


if __name__ == "__main__":
def main():
"""
CLI main function.
:return: None
"""
args = sys.argv
if len(args) > 1:
if args[1].upper() == "TEST":
Expand Down Expand Up @@ -103,3 +108,7 @@ def select_test(test_name="TEST"):
help_func()
else:
help_func()


if __name__ == "__main__":
main()
13 changes: 2 additions & 11 deletions art/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from .art_dic import *
from .art_param import *
import os
import sys
import random


Expand Down Expand Up @@ -122,16 +121,8 @@ def help_func():
"""
tprint("art")
tprint("v" + ART_VERSION)
print(DESCRIPTION + "\n")
print("Webpage : https://www.ascii-art.site\n")
print("Help : \n")
print(" - list --> (list of arts)\n")
print(" - fonts --> (list of fonts)\n")
print(" - test --> (run tests)\n")
print(" - text 'yourtext' 'font(optional)' --> (text art) Example : 'python -m art text exampletext block'\n")
print(" - shape 'shapename' --> (shape art) Example : 'python -m art shape butterfly'\n")
print(" - save 'yourtext' 'font(optional)' --> Example : 'python -m art save exampletext block'\n")
print(" - all 'yourtext' --> Example : 'python -m art all exampletext'")
print(DESCRIPTION)
print(CLI_HELP)


def aprint(artname, number=1):
Expand Down
20 changes: 20 additions & 0 deletions art/art_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@
FONT_ENVIRONMENT_WARNING = "[Warning] '{0}' is not printable in this environment."
PACKAGE_LOAD_WARNING = "[Warning] There is a problem loading the package 'coverage'."

CLI_HELP = """
Webpage : https://www.ascii-art.site
Help :
\t- list --> (list of arts)
\t- fonts --> (list of fonts)
\t- test --> (run tests)
\t- text [yourtext] [font(optional)] --> (text art) Example : 'art text exampletext block'
\t- shape [shapename] --> (shape art) Example : 'art shape butterfly'
\t- save [yourtext] [font(optional)] --> Example : 'art save exampletext block'
\t- all [yourtext] --> Example : 'art all exampletext'
"""

SMALL_WIZARD_FONT = [
"contessa",
"avatar",
Expand Down
9 changes: 5 additions & 4 deletions art/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4428,13 +4428,14 @@
<BLANKLINE>
- test --> (run tests)
<BLANKLINE>
- text 'yourtext' 'font(optional)' --> (text art) Example : 'python -m art text exampletext block'
- text [yourtext] [font(optional)] --> (text art) Example : 'art text exampletext block'
<BLANKLINE>
- shape 'shapename' --> (shape art) Example : 'python -m art shape butterfly'
- shape [shapename] --> (shape art) Example : 'art shape butterfly'
<BLANKLINE>
- save 'yourtext' 'font(optional)' --> Example : 'python -m art save exampletext block'
- save [yourtext] [font(optional)] --> Example : 'art save exampletext block'
<BLANKLINE>
- all [yourtext] --> Example : 'art all exampletext'
<BLANKLINE>
- all 'yourtext' --> Example : 'python -m art all exampletext'
>>> tprint('طط')
<BLANKLINE>
>>> art1 = "MonSter"
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,9 @@ def read_description():
'Topic :: Printing',
],
license='MIT',
include_package_data=True
include_package_data=True,
entry_points={
'console_scripts': [
'art = art.__main__:main',
]}
)

0 comments on commit cf7f6ed

Please sign in to comment.