Skip to content

Commit b81ade2

Browse files
committed
CLI first version
1 parent b57a5ad commit b81ade2

3 files changed

Lines changed: 56 additions & 6 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ jobs:
2222
python-version: ${{ matrix.python-version }}
2323
- name: Install package
2424
run: |
25-
python -m pip install --upgrade pip
26-
python -m pip install --upgrade setuptools
25+
python -m pip install --upgrade build pip setuptools
2726
python -m pip install .
2827
- name: Run test
2928
run: |
3029
python tests/test_mnemonic.py
30+
- name: Build wheel and sdist
31+
run: |
32+
python -m build
33+
- name: Check long description
34+
run: |
35+
twine check dist/*

README.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,23 @@ Abstract
1313
This BIP describes the implementation of a mnemonic code or mnemonic sentence --
1414
a group of easy to remember words -- for the generation of deterministic wallets.
1515

16-
It consists of two parts: generating the mnenomic, and converting it into a
16+
It consists of two parts: generating the mnemonic, and converting it into a
1717
binary seed. This seed can be later used to generate deterministic wallets using
1818
BIP-0032 or similar methods.
1919

2020
BIP Paper
2121
---------
2222

23-
See https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
24-
for full specification
23+
See `BIP-0039`_ for the full specification.
2524

2625
Installation
2726
------------
2827

2928
To install this library and its dependencies use:
3029

31-
``pip install mnemonic``
30+
.. code-block:: sh
31+
32+
$ pip install mnemonic
3233
3334
Usage examples
3435
--------------
@@ -75,3 +76,5 @@ Given the word list, calculate original entropy:
7576
.. code-block:: python
7677
7778
entropy = mnemo.to_entropy(words)
79+
80+
.. _BIP-0039: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

src/mnemonic/cli.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import click
2+
3+
from mnemonic import Mnemonic
4+
5+
6+
@click.group()
7+
def cli() -> None:
8+
pass
9+
10+
11+
@cli.command()
12+
@click.option(
13+
"-l",
14+
"--language",
15+
default="english",
16+
type=str,
17+
help="",
18+
)
19+
@click.option(
20+
"-s",
21+
"--strength",
22+
default=128,
23+
type=int,
24+
help="",
25+
)
26+
@click.option("-p", "--passphrase", default="", type=str, help="")
27+
def create(
28+
language: str,
29+
passphrase: str,
30+
strength: int,
31+
) -> None:
32+
""" """
33+
mnemo = Mnemonic(language)
34+
words = mnemo.generate(strength)
35+
seed = mnemo.to_seed(words, passphrase)
36+
click.secho("SUCCESS!", fg="green", bold=True)
37+
click.echo(f"Mnemonic: {words}")
38+
click.echo(f"Seed: {seed.hex()}")
39+
40+
41+
if __name__ == "__main__":
42+
cli()

0 commit comments

Comments
 (0)