Skip to content

Commit

Permalink
Tambahkan antarmuka CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
prasastoadi authored and laymonage committed Mar 17, 2020
1 parent 323aed9 commit a5fcbbf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ pip install kbbi

### Manual

1. Lakukan instalasi untuk paket-paket prasyarat ([`requests`][requests]
dan [`BeautifulSoup4`][beautifulsoup4]).
1. Lakukan instalasi untuk paket-paket prasyarat ([`requests`][requests], [`BeautifulSoup4`][beautifulsoup4], dan [`Abseil`][abseil]).
2. Klonakan repositori ini atau unduh [`kbbi.py`][kbbi-py].
3. Letakkan `kbbi.py` dalam direktori yang Anda inginkan.

Expand Down Expand Up @@ -113,6 +112,22 @@ tak.sir [2]
}
```

Penggunaan melalui CLI.
```
$ python kbbi.py --kata=cinta
```

Pencarian frasa yang dipisahkan oleh spasi harus diapit oleh tanda petik.
```
$ python kbbi.py --kata="tanggung jawab"
```

Menambahkan contoh kalimat.
```
$ python kbbi.py --kata="tanggung jawab" --contoh
```


## Lisensi

Proyek ini didistribusikan dengan lisensi [MIT][license].
Expand All @@ -131,6 +146,7 @@ penyalahgunaan yang mungkin muncul dari proyek ini.
[kbbi]: https://kbbi.kemdikbud.go.id
[requests]: https://pypi.org/project/requests
[beautifulsoup4]: https://pypi.org/project/requests/beautifulsoup4
[abseil]: https://github.com/abseil/abseil-py
[kbbi-py]: kbbi/kbbi.py
[license]: LICENSE
[hukum]: https://kbbi.kemdikbud.go.id/Beranda/Hukum
Expand Down
24 changes: 24 additions & 0 deletions kbbi/kbbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
import requests
from bs4 import BeautifulSoup

from absl import app
from absl import flags


FLAGS = flags.FLAGS

flags.DEFINE_string("kata", None, "Kata yang dicari.")
flags.DEFINE_boolean("contoh", False, 'Menampilkan contoh kalimat.')

flags.mark_flag_as_required('kata')

class KBBI:
"""Sebuah laman dalam KBBI daring."""
Expand Down Expand Up @@ -397,3 +407,17 @@ def __init__(self):
super().__init__(
"Pencarian Anda telah mencapai batas maksimum dalam sehari."
)


def main(argv):

kata = KBBI(FLAGS.kata)
contoh = False
if FLAGS.contoh:
contoh = True

print(kata.__str__(contoh=contoh))


if __name__ == '__main__':
app.run(main)
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"kbbi kamus bahasa indonesia indonesian natural language scraper"
),
packages=find_packages(),
install_requires=["requests", "beautifulsoup4",],
python_requires=">=3.6",
install_requires=[
'requests',
'beautifulsoup4',
'absl-py',
],
)

0 comments on commit a5fcbbf

Please sign in to comment.