From 7bf3b19100140ecca72a36b57f33680d16074275 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Mon, 2 Nov 2020 16:08:56 +0530 Subject: [PATCH] Add argument parsing in create_app.py --- create_app.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 create_app.py diff --git a/create_app.py b/create_app.py new file mode 100755 index 0000000..556bfc0 --- /dev/null +++ b/create_app.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +"Creates a firefox " + +import argparse +import sys +import os.path as pt + +def main(): + "Main Function" + parser = argparse.ArgumentParser() + parser.add_argument("url", help="URL for the webapp") + parser.add_argument( + "-n", "--name", + help=("Name of the app as shown in the menu. In absence of this, the " + "title of page will be used.") + ) + + parser.add_argument( + "-e", "--exec-name", + help="Name of the script that will be created in binary directory." + ) + + parser.add_argument( + "-l", "--logo", + help="URL/path for the logo. If omitted, the favicon will be used." + ) + + parser.add_argument( + "-f", "--firefox-profile", + help="Firefox Profile path. If omitted, the default profile is used" + ) + args = parser.parse_args() + + # Add Missing Arguments with default values + if args.firefox_profile is None: + profile_path = pt.dirname(sys.argv[0]) + "/.firefox_profile" + with open(profile_path) as prof: + args.firefox_profile = prof.readline()[:-1] + print(args) + + +if __name__ == "__main__": + main()