Skip to content

Commit

Permalink
Merge pull request #46 from codePerfectPlus/dev
Browse files Browse the repository at this point in the history
better cli output
  • Loading branch information
DrakeEntity authored Nov 3, 2022
2 parents d10d121 + dc8693b commit e43ee9f
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 50 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ All notable changes to this project will be documented in this file. The format

## Changelog

## [Unreleased]
## [0.2.4]

- Beautiful command line output
- Moved test files to random_profile to avoid flake8:402 error
- Following proper changelog format, added changelog file
- Added config for readthedocs
- Docs: Added documentation for the project
- Bug fixed: Fixed a bug with random_profile import

## [v0.2.3] - 13-10-2022

Expand Down
23 changes: 15 additions & 8 deletions docs/command_line_usage.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Command line usages
=========
===================

`Random Profile Generator` can be used as a command line tool.
It can be used to generate a random profile and save it to a file.
Expand All @@ -25,55 +25,62 @@ Usages:
-j, --jobtitle Get job title
Get Random Profile:
------------
-------------------

.. code-block:: bash
# n = number of random profiles, p = profile
random_profile -n 10 -p
Get First Name:
------------
---------------

.. code-block:: bash
# n = number of random profiles, f = first name
random_profile -n 10 -f
Get Last Name:
------------
--------------

.. code-block:: bash
# n = number of random profiles, l = last name
random_profile -n 10 -l
Get Job Title:
------------
--------------

.. code-block:: bash
# n = number of random profiles, j = job title
random_profile -n 10 -j
Get IPv4 Address:
------------
-----------------

.. code-block:: bash
# n = number of random profiles, ip = ipv4
random_profile -n 10 -ip
Get Random Profile and Save to File:
------------
------------------------------------

.. code-block:: bash
# n = number of random profiles, p = profile
random_profile -n 10 -p > random_profiles.txt
.. code-block:: bash
# save to a file
# n = number of random profiles, p = profile
random_profile -n 10 -p >> random_profiles.txt
Get Random Profile version:
------------
---------------------------

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion docs/import_as_module.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import as module
------------
----------------

You can import the module and use it in your own scripts.

Expand Down
27 changes: 11 additions & 16 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
.. rst-class:: hide-header

Welcome to RandomProfileGenerator's documentation!
=====================================
=================================================

|PyPI download month|
|Total download|

.. |PyPI download month| image:: https://img.shields.io/pypi/dm/random_profile.svg
.. |Total download| image:: http://pepy.tech/badge/random_profile
:target: https://pypi.python.org/pypi/random_profile/

|PyPI version fury.io|
Expand Down Expand Up @@ -41,21 +41,11 @@ If you love open source contributions.
* Join the community on `Discord <https://discord.gg/JfbK3bS>`_.
* join the community on `Github <https://github.com/Py-Contributors/support/issues/new?assignees=&labels=invite+me+to+the+organisation&template=invite.yaml&title=Please+invite+me+to+the+GitHub+Community+Organization>`_.

Other Projects by Py-Contributors:
--------------

* `AudioBook <https://audiobook.readthedocs.io/en/latest//>`_
* `Cybel - The Discord Bot <https://github.com/Py-Contributors/Cybel>`_
* `Twitterify - Tweet-retweet bot <https://github.com/Py-Contributors/twitterify>`_

|forthebadge made-with-python|

.. |forthebadge made-with-python| image:: http://ForTheBadge.com/images/badges/made-with-python.svg
:target: https://www.python.org/

Contents:
---------

.. toctree::
:hidden:
:maxdepth: 2

introduction.rst
installation.rst
Expand All @@ -65,4 +55,9 @@ Other Projects by Py-Contributors:
roadmap.rst
run_test_cases.rst

Other Projects by Py-Contributors:
---------------------------------

* `AudioBook <https://audiobook.readthedocs.io/en/latest//>`_
* `Cybel - The Discord Bot <https://github.com/Py-Contributors/Cybel>`_
* `Twitterify - Tweet-retweet bot <https://github.com/Py-Contributors/twitterify>`_
9 changes: 5 additions & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Installation
=========
============

Install Via Pip(recommended):
------------
----------------------------

.. code-block:: bash
Expand All @@ -11,16 +11,17 @@ Install Via Pip(recommended):
Install from Source(Unreleased):
------------
--------------------------------

.. code-block:: bash
git clone https://github.com/Py-Contributors/RandomProfileGenerator
git checkout main
cd RandomProfileGenerator
python setup.py install
Test Installation:
------------
-----------------

.. code-block:: bash
Expand Down
8 changes: 1 addition & 7 deletions docs/introduction.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Introduction
=========
============

`RandomProfileGenerator` is a powerful and simple tool to generate fake data.
You can use it to mock classes, populate databases and much more.
Expand All @@ -18,9 +18,3 @@ Use cases
- Generating fake data for your demo
- Generating fake data for your blog post

Upcoming features
------------

- Support for more languages (Javascript)


2 changes: 1 addition & 1 deletion docs/roadmap.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Roadmap and future plans
=========
========================

* `more test coverage`
* `more supported file formats`
Expand Down
11 changes: 9 additions & 2 deletions docs/run_test_cases.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
Run test cases
=========
==============

For the test cases, we are using `pytest`. The test cases are located in the `tests` directory. To run the test cases, you can use the following command:


.. code-block:: bash
$ pytest tests
pytest tests
.. code-block:: bash
flake8 . --ignore=E501
You can also run the test cases with coverage:

Empty file added log/__init__.py
Empty file.
15 changes: 8 additions & 7 deletions random_profile/__main__.py → random_profile/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from audiobook.main import RandomProfile
from random_profile.main import RandomProfile
import argparse
from pprint import pprint


def main():
Expand Down Expand Up @@ -42,17 +43,17 @@ def main():

rp = RandomProfile(args.n)
if args.fullname:
print(*rp.full_name(), sep="\n")
pprint(rp.full_name())
elif args.profile:
print(*rp.full_profile(), sep="\n")
pprint(rp.full_profile())
elif args.lastname:
print(*rp.last_name(), sep="\n")
pprint(rp.last_name())
elif args.jobtitle:
print(*rp.job_title(), sep="\n")
pprint(rp.job_title())
elif args.ipv4:
print(*rp.ipv4(), sep="\n")
pprint(rp.ipv4())
else:
print('Type `random_profile -h` for help')
pprint('Type `random_profile -h` for help')


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion random_profile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ASSETS_DIR = os.path.join(ROOT_DIR, "random_profile", "assets")
logging.basicConfig(filename='log/example.log', encoding='utf-8', level=logging.DEBUG)
logging.basicConfig(filename='log/example.log', level=logging.DEBUG)


def load_txt_file(file_name: str) -> list:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"Topic :: Utilities",
"Environment :: Plugins"],
entry_points={
"console_scripts": ["random_profile = random_profile.__main__:main"],
"console_scripts": ["random_profile = random_profile.cli:main"],
},
)

0 comments on commit e43ee9f

Please sign in to comment.