{"id":19483187,"url":"https://github.com/mmgrant73/easygetopt","last_synced_at":"2025-10-04T01:52:23.767Z","repository":{"id":10627348,"uuid":"12850133","full_name":"mmgrant73/easygetopt","owner":"mmgrant73","description":"easygetopt is a python script that generates code for parsing command line arguments by just answering a couple of question.","archived":false,"fork":false,"pushed_at":"2013-09-15T18:58:59.000Z","size":116,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-08T07:31:15.752Z","etag":null,"topics":["parsing","python","python-script"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmgrant73.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-15T18:22:56.000Z","updated_at":"2014-05-01T10:15:07.000Z","dependencies_parsed_at":"2022-09-22T20:23:00.365Z","dependency_job_id":null,"html_url":"https://github.com/mmgrant73/easygetopt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmgrant73%2Feasygetopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmgrant73%2Feasygetopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmgrant73%2Feasygetopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmgrant73%2Feasygetopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmgrant73","download_url":"https://codeload.github.com/mmgrant73/easygetopt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240718893,"owners_count":19846481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parsing","python","python-script"],"created_at":"2024-11-10T20:13:55.340Z","updated_at":"2025-10-04T01:52:18.734Z","avatar_url":"https://github.com/mmgrant73.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"Easygetopt\n==========\n\neasygetopt is a python script that generates code in python for parsing command line arguments by just answering a couple of question.\n\nI wrote this script because I found myself copy and pasting the code for dealing with command line options using getopt from one project to another.\nThus, like any good programmer I decided to automate the process.  This is a useful script when you are beginning a need program in python.\nJust run the script, answer the questions that are prompted and the program will create a new python file with the command line parsing already done for you.\n\nRequirments:\n------------\n* Just need to make sure python and its standard library are installed on your computer\n\nUsage:\n------\nJust download the script (flagcreator.py) and than go to the folder that has the Easygetopt.  After which type the following into the terminal window.\n\n```\n# run the script \n# -o option is the file name of the file you want to create with this script\npython ./flagcreator.py -o test.py \n\nfile = test.py\n--------------flag creator -----------------\nJust answer the questions and the flags will be set up for you\n--------------------------------------------\nWhat is the letter for the flag? a  \nThe flag is -a                      # letter that will represent the option (-a)\nWhat is the long name for the flag -a Just leave blank if you do not want a longname all\nThe long name for flag -a is all    # longname of the option (--all)\nDoes this flag has parameter data: (y)es or(n)o y  #Does the option have data with it (-a testfile)\nWhat is the variable name for the flag -a? files   #The data will be stored this variable (files = testfile)\nThe variable for flag -a is files\nDo you want to add another flag: (y)es or(n)o y # Do you want to add another option\n-------------------------------------\nWhat is the letter for the flag? b\nThe flag is -b\nWhat is the long name for the flag -b Just leave blank if you do not want a longname bug\nThe long name for flag -b is bug\nDoes this flag has parameter data: (y)es or(n)o n\nThe flag does not have any data to go with it\nDo you want to add another flag: (y)es or(n)o y\n-------------------------------------\nWhat is the letter for the flag? c\nThe flag is -c\nWhat is the long name for the flag -c Just leave blank if you do not want a longname cat\nThe long name for flag -c is cat\nDoes this flag has parameter data: (y)es or(n)o y\nWhat is the variable name for the flag -c? pet\nThe variable for flag -c is pet\nDo you want to add another flag: (y)es or(n)o n\nDone adding flags....\n-------------------------------------\nFinished!!!\n\n```\nAfter answering these question, a new python file called test.py is created for you.  The output file for test.py is shown below.\n```\n#-------------------------------\n#!/usr/bin/python\n#-----------------------FlagCreator-------------------------------\n#Flagcreator by Matthew Grant\n#flagcreator was used to create the flags/switches in this program\n#Free to use as you wish\n#Proud member of the zeitgeist movement\n#-----------------------------------------------------------------\nimport sys, getopt\n#----------Global Variable List---------------\nfiles=''\npet=''\n#----------Functions---------------------------\ndef usage():\n# This is the function that handles the help flag\n\t\tprint 'FlagCreator Help'\n\t\treturn\n\ndef main(argv):\n\t\ttry:\n\t\t\topts, args = getopt.getopt(argv, 'ha:bc:',['help=''all=','bug=','cat='])\n\t\texcept getopt.GetoptError:\n\t\t\tprint 'There was an error in the format of FileCreator option'\n                        print 'Enter filecreator.py -h for help'\n\t\t\tsys.exit(2)\n\t\tfor opt, arg in opts:\n\t\t\tif opt in ('-h', '--help'):\n\t\t        \tusage()\n\t\t\t        sys.exit()\n\t\t\telif opt in ('-a','--all='):\n\t\t\t\tglobal files\n\t\t\t\tfiles=arg\n\t\t\t\t# replace with a call to a function to handle this flag\n\t\t\telif opt in ('-b','--bug='):\n\t\t\t\t# replace with a call to a function to handle this flag\n\t\t\telif opt in ('-c','--cat='):\n\t\t\t\tglobal pet\n\t\t\t\tpet=arg\n\t\t\t\t# replace with a call to a function to handle this flag\n\t\t\t\n#-------------Main Body of the Program--------\nif __name__ == \"__main__\":\n\t\tmain(sys.argv[1:])\n#---------------------------------------------\n\n```\nNote: You do not have to add the -h (--help) option as it is automatically added for you.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmgrant73%2Feasygetopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmgrant73%2Feasygetopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmgrant73%2Feasygetopt/lists"}