Skip to content

Commit

Permalink
Exit bug (#114)
Browse files Browse the repository at this point in the history
* fix : CLI main function updated

* fix : get_input_standard function error handler updated

* doc : CHANGELOG.md updated
  • Loading branch information
sepandhaghighi authored Dec 21, 2024
1 parent 9ff40d5 commit 5249a75
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- `README.md` modified
- `AUTHORS.md` updated
- Exit bug fixed
## [0.8] - 2024-11-04
### Added
- Balancing program
Expand Down
62 changes: 31 additions & 31 deletions nafas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ def main():
:return:
"""
parser = argparse.ArgumentParser()
parser.add_argument('--version', help='version', nargs="?", const=1)
parser.add_argument('--silent', help='silent mode', nargs="?", const=1)
args = parser.parse_args()
silent_flag = args.silent
if args.version:
print(NAFAS_VERSION)
else:
tprint("Nafas")
tprint("v" + str(NAFAS_VERSION))
if silent_flag:
tprint("Silent Mode")
description_print()
EXIT_FLAG = False
while not EXIT_FLAG:
input_data = get_input_standard()
filtered_data = input_filter(input_data)
program_name, level, program_data = get_program_data(filtered_data)
program_description_print(program_name, level, program_data)
run(program_data, silent=silent_flag)
INPUTINDEX = str(
input("Press [R] to restart or any other key to exit."))
if INPUTINDEX.upper() != "R":
EXIT_FLAG = True
print(EXIT_MESSAGE)
else:
clear_screen()


if __name__ == "__main__":
try:
main()
parser = argparse.ArgumentParser()
parser.add_argument('--version', help='version', nargs="?", const=1)
parser.add_argument('--silent', help='silent mode', nargs="?", const=1)
args = parser.parse_args()
silent_flag = args.silent
if args.version:
print(NAFAS_VERSION)
else:
tprint("Nafas")
tprint("v" + str(NAFAS_VERSION))
if silent_flag:
tprint("Silent Mode")
description_print()
EXIT_FLAG = False
while not EXIT_FLAG:
input_data = get_input_standard()
filtered_data = input_filter(input_data)
program_name, level, program_data = get_program_data(filtered_data)
program_description_print(program_name, level, program_data)
run(program_data, silent=silent_flag)
INPUTINDEX = str(
input("Press [R] to restart or any other key to exit."))
if INPUTINDEX.upper() != "R":
EXIT_FLAG = True
print(EXIT_MESSAGE)
else:
clear_screen()
except (KeyboardInterrupt, EOFError):
print("\n" + EXIT_MESSAGE)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion nafas/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def get_input_standard(input_func=input):
try:
input_data[item] = int(input_func(""))
exit_flag = True
except KeyboardInterrupt:
except (KeyboardInterrupt, EOFError):
print("\n" + EXIT_MESSAGE)
sys.exit()
except Exception:
Expand Down

0 comments on commit 5249a75

Please sign in to comment.