{"id":27076217,"url":"https://github.com/aidinhamedi/python-check-arg","last_synced_at":"2025-07-22T01:31:59.348Z","repository":{"id":205230704,"uuid":"713735310","full_name":"AidinHamedi/Python-check-arg","owner":"AidinHamedi","description":"The check_arg function is a handy Python code snippet that checks if a specific argument exists in a list of arguments. It's a reusable piece of code that you can easily integrate into your projects.","archived":false,"fork":false,"pushed_at":"2023-11-04T11:33:05.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T00:28:57.709Z","etag":null,"topics":["argv","argv-parser","cli","functional","python","python-3","python3","snippets","user-interface"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AidinHamedi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-03T06:13:36.000Z","updated_at":"2023-12-31T07:25:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"b76a6198-e5f7-45f4-a175-b2a76bf1b442","html_url":"https://github.com/AidinHamedi/Python-check-arg","commit_stats":null,"previous_names":["aydinhamedi/python-check-arg","aidinhamedi/python-check-arg"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AidinHamedi/Python-check-arg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-check-arg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-check-arg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-check-arg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-check-arg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AidinHamedi","download_url":"https://codeload.github.com/AidinHamedi/Python-check-arg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-check-arg/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266409479,"owners_count":23924284,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["argv","argv-parser","cli","functional","python","python-3","python3","snippets","user-interface"],"created_at":"2025-04-06T00:29:00.941Z","updated_at":"2025-07-22T01:31:59.320Z","avatar_url":"https://github.com/AidinHamedi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python-check-arg\n\u003cimg src=\"https://img.shields.io/badge/Python-FFD43B?style=for-the-badge\u0026logo=python\u0026logoColor=blue\"/\u003e\n\nThe `check_arg` function is a handy Python code snippet that checks if a specific argument exists in a list of arguments. It's a reusable piece of code that you can easily integrate into your projects.\n\n## Function Signature\n\n```python\ndef check_arg(arg_list: list, arg_str: str, return_arg: bool = False, bool_OUTPUT_ONLY: bool = False):\n```\n\n## Parameters\n\n- `arg_list` (list): A list of arguments.\n- `arg_str` (str): The argument to check for.\n- `return_arg` (bool, optional): If True, returns the string after the argument if it exists. Defaults to False.\n- `bool_OUTPUT_ONLY` (bool, optional): If True, only boolean values are returned. If False, specific error codes are returned in case of errors. Defaults to False.\n\n## Returns\n\n- `bool/str`: Returns True if the argument exists and `return_arg` is False. Returns the string after the argument if `return_arg` is True and the argument exists. Returns specific error codes in case of errors, unless `bool_OUTPUT_ONLY` is True.\n\n## Error Codes\n\n- '![IER:01]': Returned when the provided argument list is empty or contains only 'none' or ''.\n- '![IER:02]': Returned when the argument to check for is an empty string.\n- '![IER:03]': Returned when the argument is found in the argument list, but there is no string after the argument and `return_arg` is set to True.\n- '![IER:04]': Returned when the argument is not found in the argument list.\n\nNote: If the `bool_OUTPUT_ONLY` parameter is set to True, the function will return False instead of these error codes.\n\n## Usage Examples\n\n```python\n# Example 1: Check if '-v' exists in the argument list\nargs = ['-v', '-f', 'file.txt']\nprint(check_arg(args, 'v'))  # Returns: True\n\n# Example 2: Get the string after '-z' in the argument list\nargs = ['-v', '-f', '-z12']\nprint(check_arg(args, 'z', return_arg=True))  # Returns: '12'\n\n# Example 3: Check for an argument that doesn't exist in the list\nargs = ['-v', '-f', 'file.txt']\nprint(check_arg(args, 'x'))  # Returns: '![IER:04]' or False if bool_OUTPUT_ONLY is True\n```\n\nFeel free to copy this code snippet and use it in your projects. If you find any issues or have any suggestions for improvements, please open an issue or submit a pull request.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidinhamedi%2Fpython-check-arg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faidinhamedi%2Fpython-check-arg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidinhamedi%2Fpython-check-arg/lists"}