Skip to content

Commit

Permalink
Silent mode (#101)
Browse files Browse the repository at this point in the history
* feat : silent mode added

* fix : tests updated

* doc : README.md updated

* doc : CHANGELOG.md updated

* doc : README.md updated

* fix : minor edit in main function
  • Loading branch information
sepandhaghighi authored Sep 14, 2024
1 parent c7c0032 commit 231322a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]
### Added
- `--silent` argument
- `clear_screen` function
### Changed
- Restart mode updated
Expand Down
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,37 @@ No need to walk away to take a break, just sit comfortably, run Nafas and let th
- `pip install nafas==0.7`


### Exe Version (Only Windows)
### Exe Version

⚠️ Only Windows

- Download [Exe-Version 0.7](https://github.com/sepandhaghighi/nafas/releases/download/v0.7/NAFAS-0.7.exe)
- Run `NAFAS-0.7.exe`


## Usage

- Open `CMD`/`PowerShell` (Windows) or `Terminal` (Linux)
- Run `nafas` or `python -m nafas` (or run `NAFAS.exe`)
- Enter data
ℹ️ You can use `nafas`, `python -m nafas` or `NAFAS.exe` to run this program

### Version

```console
nafas --version
```

### Basic

```console
nafas
```

### Silent Mode

ℹ️ This mode will disable the sound playing system

```console
nafas --silent
```

<div align="center">

Expand Down
6 changes: 5 additions & 1 deletion nafas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@ def 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)
run(program_data, silent=silent_flag)
INPUTINDEX = str(
input("Press [R] to restart or any other key to exit."))
if INPUTINDEX.upper() != "R":
Expand Down
8 changes: 6 additions & 2 deletions nafas/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,19 @@ def play_sound(sound_path, enable=True):
_ = nava.play(sound_path, async_mode=True)


def run(program_data):
def run(program_data, silent=False):
"""
Run program.
:param program_data: program data
:type program_data: dict
:param silent: silent mode flag
:type silent: bool
:return: None
"""
sound_check_flag = sound_check()
sound_check_flag = False
if not silent:
sound_check_flag = sound_check()
cycle = program_data["cycle"]
ratio = program_data["ratio"]
unit = program_data["unit"]
Expand Down
18 changes: 18 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@
. . .
######################################################################
Well done!
>>> run({'cycle': 2, 'pre': 3, 'unit': 1, 'ratio': [1, 0, 3, 0]}, silent=True)
Preparing . . .
######################################################################
Start
######################################################################
Cycle : 1 (Remaining : 1)
- Inhale for 1 sec
.
- Exhale for 3 sec
. . .
######################################################################
Cycle : 2 (Remaining : 0)
- Inhale for 1 sec
.
- Exhale for 3 sec
. . .
######################################################################
Well done!
>>> run({'cycle': 2, 'pre': 3, 'unit': 1, 'ratio': [1, 0, 3.3, 0]})
Preparing . . .
######################################################################
Expand Down

0 comments on commit 231322a

Please sign in to comment.