-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.py
More file actions
44 lines (32 loc) · 1.08 KB
/
cli.py
File metadata and controls
44 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
import click
import humanize
from getpass import getpass
from codetoname import log, report
from codetoname.crawler import Crawler
# hooking log
sys.excepthook = log.except_hooking
@click.command()
@click.option('--begin', default=0, help='begin index of page')
@click.option('--end', default=1, help='end index of page')
@click.option('--size', default=-1, help='size of page')
def cli_crawler(begin, end, size):
account = input('Github account or email: ')
password = getpass('Github password: ')
begin = max(0, begin)
if size <= 0:
client = Crawler(account=account, password=password, page_num=begin)
else:
client = Crawler(account=account, password=password, page_num=begin, page_size=size)
for i in range(begin, end):
client.next()
@click.command()
def cli_total_repos():
print(humanize.intcomma(Crawler().num_repos()))
@click.command()
def cli_total_features():
print(humanize.intcomma(Crawler().num_features()))
@click.command()
def cli_report_first_words():
for word in report.first_words():
print(word)