-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsayer.py
executable file
·65 lines (47 loc) · 1.37 KB
/
sayer.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
import fire
class Hello:
'''Hello group of commands, there is a to and a everyone
command
'''
def __init__(self, name):
self.name = name
def to(self, name=None):
if name is None:
if self.name is None:
return 'No one to say hello to'
else:
return f'Hello to {self.name}'
else:
return f'Hello {name}'
def everyone(self):
return 'hello to everyone'
class Bye:
'''Bye group of commands, there is a to and a no_one
command
'''
def __init__(self, name):
self.name = name
def to(self, name=None):
if name is None:
if self.name is None:
return 'No one to say bye to'
else:
return f'Bye to {self.name}'
else:
return f'Bye {name}'
def no_one(self):
return f'Bye to no one'
class Sayer:
'''Class to make the hello and bye groups available, it
also has its own to command, as well as the info command
'''
def __init__(self, hello_name=None, bye_name=None):
self.hello = Hello(hello_name)
self.bye = Bye(bye_name)
def to(self):
return 'Do you want to say hello or bye?'
def info(self):
return 'This is version 0.1beta'
if __name__ == '__main__':
fire.Fire(Sayer)