Compare commits
3 Commits
master
...
feat/argpa
| Author | SHA1 | Date |
|---|---|---|
|
|
7e138615b7 | |
|
|
90aba43e1e | |
|
|
131443b7c5 |
|
|
@ -25,4 +25,4 @@ Homepage = "https://github.com/gmbrax/Pilgrim/"
|
|||
Issues = "https://github.com/gmbrax/Pilgrim/issues"
|
||||
|
||||
[project.scripts]
|
||||
pilgrim = "epstein.command:main"
|
||||
epstein = "epstein.command:main"
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
import argparse
|
||||
import sys
|
||||
|
||||
class Application:
|
||||
def __init__(self):
|
||||
self.args = self.__setup_args
|
||||
|
||||
@property
|
||||
def __setup_args(self):
|
||||
parser = argparse.ArgumentParser(prog="epstein",
|
||||
description='Test for PDF Export Module for pilgrim')
|
||||
|
||||
subparsers = parser.add_subparsers(dest="command",required=True)
|
||||
print_parser = subparsers.add_parser("print", help="generate the PDF file ")
|
||||
print_parser.add_argument("-t", "--theme", required=True, help="Define the theme to use.")
|
||||
print_parser.set_defaults(func=self.handle_print)
|
||||
|
||||
|
||||
theme_parser = subparsers.add_parser("theme", help="Manage the themes")
|
||||
theme_subparsers = theme_parser.add_subparsers(dest="theme_action", help="Actions for the themes" , required=True)
|
||||
|
||||
theme_create_parser = theme_subparsers.add_parser("create", help="Create a new theme")
|
||||
theme_create_parser.add_argument("-n", "--name", required=True, help="Name of the theme")
|
||||
theme_create_parser.set_defaults(func=self.handle_theme_create)
|
||||
|
||||
theme_list_parser = theme_subparsers.add_parser("list", help="List all the themes")
|
||||
theme_list_parser.set_defaults(func=self.handle_theme_list)
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1] == 'theme':
|
||||
theme_parser.print_help(sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help(sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
def handle_print(self):
|
||||
print("handle print")
|
||||
|
||||
def handle_theme_create(self):
|
||||
print("handle theme create")
|
||||
|
||||
def handle_theme_list(self):
|
||||
print("handle theme list")
|
||||
|
||||
def run(self):
|
||||
self.args.func()
|
||||
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
from epstein.application import *
|
||||
import argparse
|
||||
|
||||
from epstein.application import Application
|
||||
|
||||
def main():
|
||||
print("hello world")
|
||||
app = Application()
|
||||
app.run()
|
||||
|
||||
if __name__ =="__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue