-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from LanceMaverick/my-new-stache
Implemented first draft of moustaches
- Loading branch information
Showing
6 changed files
with
111 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
from pathlib import Path | ||
|
||
from utils import make_init_text | ||
|
||
|
||
def make_file(name, filename=None): | ||
if filename is not None: | ||
path = Path(filename) | ||
else: | ||
path = Path(name+".py") | ||
|
||
init_text = make_init_text(name) | ||
|
||
with path.open("w") as f: | ||
f.write(init_text) | ||
|
||
print("Moustache created as: {}".format(str(path))) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description='Create new moustache.') | ||
parser.add_argument('name', help="Name of beard.") | ||
parser.add_argument('-f', '--filename', type=str, default=None, | ||
help="Optionally specify filename.") | ||
|
||
parsed = parser.parse_args() | ||
make_file(parsed.name, parsed.filename) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from pathlib import Path | ||
|
||
import stringcase | ||
|
||
|
||
def make_init_text(name): | ||
init_text = ''' | ||
from skybeard.beards import BeardChatHandler | ||
from skybeard.decorators import onerror | ||
from skybeard.utils import get_args | ||
class {beardclassname}(BeardChatHandler): | ||
__userhelp__ = """Default help message.""" | ||
__commands__ = [ | ||
# command, callback coro, help text | ||
("echo", 'echo', 'Echos arguments. e.g. <code>/echo [arg1 [arg2 ... ]]</code>') | ||
] | ||
# __init__ is implicit | ||
@onerror | ||
async def echo(self, msg): | ||
args = get_args(msg) | ||
if args: | ||
await self.sender.sendMessage("Args: {{}}".format(args)) | ||
else: | ||
await self.sender.sendMessage("No arguments given.") | ||
'''.strip().format(beardclassname=stringcase.pascalcase(name)) | ||
|
||
return init_text |