Exit the application with an optional exit code. Usage: exit [exit_code] Where: * exit_code - integer exit code to return to the shell
(self, arg_list)
| 3614 | |
| 3615 | @cmd2.with_argument_list |
| 3616 | def do_exit(self, arg_list) -> bool: |
| 3617 | """Exit the application with an optional exit code. |
| 3618 | |
| 3619 | Usage: exit [exit_code] |
| 3620 | Where: |
| 3621 | * exit_code - integer exit code to return to the shell |
| 3622 | """ |
| 3623 | # If an argument was provided |
| 3624 | if arg_list: |
| 3625 | try: |
| 3626 | self.exit_code = int(arg_list[0]) |
| 3627 | except ValueError: |
| 3628 | self.perror(f"{arg_list[0]} isn't a valid integer exit code") |
| 3629 | self.exit_code = 1 |
| 3630 | |
| 3631 | # Return True to stop the command loop |
| 3632 | return True |
| 3633 | |
| 3634 | def postloop(self) -> None: |
| 3635 | """Hook method executed once when the cmdloop() method is about to return.""" |