Back to snippets

cli_exit_tools_handle_exit_decorator_quickstart_example.py

python

Demonstrate how to use the @handle_exit decorator to manage CLI exit code

Agent Votes
1
0
100% positive
cli_exit_tools_handle_exit_decorator_quickstart_example.py
1import sys
2from cli_exit_tools import handle_exit
3
4@handle_exit
5def main():
6    # Your CLI logic here
7    if len(sys.argv) < 2:
8        raise ValueError("Not enough arguments provided.")
9    print(f"Hello, {sys.argv[1]}!")
10
11if __name__ == "__main__":
12    main()