Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from daveygit2050/FR-18-application
Browse files Browse the repository at this point in the history
FR-18 Add CLI application
  • Loading branch information
daveygit2050 authored Apr 9, 2019
2 parents a0656f1 + 30c74d4 commit 7baad6b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# fraise

A Python module for generating `correct horse battery staple` like random pass phrases.
A Python module for generating `correct horse battery staple` like random passphrases.

## Installation

Expand All @@ -9,6 +9,35 @@ pip install fraise
```

## Usage

### As an application

```bash
$ fraise --help
```

```
usage: fraise [-h] [--max-word-length MAX_WORD_LENGTH]
[--minimum-length MINIMUM_LENGTH] [--separator SEPARATOR]
[--word-count WORD_COUNT]
Generate memorable passphrases
optional arguments:
-h, --help show this help message and exit
--max-word-length MAX_WORD_LENGTH
The maximum length of each word (default 8)
--minimum-length MINIMUM_LENGTH
Minimum length of the phrase (default 16)
--separator SEPARATOR
What to put inbetween the words (default space)
--word-count WORD_COUNT
How many words to include in the phrase (default 4)
```

### As a library

```python
>>> import fraise

Expand Down
38 changes: 38 additions & 0 deletions fraise/application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import argparse

from . import phrases


def get_args():
parser = argparse.ArgumentParser(description="Generate memorable passphrases")
parser.add_argument('--max-word-length',
default=8,
dest='max_word_length',
help="The maximum length of each word (default 8)",
type=int)
parser.add_argument('--minimum-length',
default=6,
dest='minimum_length',
help="Minimum length of the phrase (default 16)",
type=int)
parser.add_argument('--separator',
default=' ',
dest='separator',
help="What to put inbetween the words (default space)"
)
parser.add_argument('--word-count',
default=4,
dest='word_count',
help="How many words to include in the phrase (default 4)",
type=int)
return parser.parse_args()


def run():
args = get_args()
print(phrases.generate(
max_word_length=args.max_word_length,
minimum_length=args.minimum_length,
separator=args.separator,
word_count=args.word_count
))
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from setuptools import setup, find_packages

setup(name='fraise',
version='1.3.0',
version='1.4.0',
description='Generate memorable pass phrases',
url='http://github.com/daveygit2050/fraise',
author='Dave Randall',
author_email='[email protected]',
license='Apache v2',
packages=find_packages(exclude=('tests', 'docs', 'target')),
zip_safe=False)
zip_safe=False,
entry_points={'console_scripts': ['fraise=fraise.application:run']})

0 comments on commit 7baad6b

Please sign in to comment.