25 lines
605 B
Python
25 lines
605 B
Python
class ExtraCommands:
|
|
@staticmethod
|
|
def do_greet(args):
|
|
"""Greet someone: greet <name>"""
|
|
name = args if args else "World"
|
|
return f"Hello, {name}!"
|
|
|
|
@staticmethod
|
|
def do_reverse(args):
|
|
"""Reverse a string: reverse <string>"""
|
|
return args[::-1]
|
|
|
|
@staticmethod
|
|
def do_count(args):
|
|
"""Count words in a string: count <string>"""
|
|
return str(len(args.split()))
|
|
|
|
commands = {
|
|
'greet': ExtraCommands.do_greet,
|
|
'reverse': ExtraCommands.do_reverse,
|
|
'count': ExtraCommands.do_count,
|
|
}
|
|
|
|
def get_commands():
|
|
return commands |