Skip to content

Commit

Permalink
Version (#7)
Browse files Browse the repository at this point in the history
* feat : --version flag added

* doc : README updated
  • Loading branch information
sepandhaghighi committed Nov 3, 2022
1 parent c7a7516 commit afb318f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- `--version` flag
### Changed
- Test system modified
- `countdown_timer` function modified
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ Simple timer for your terminal!

⚠️ You can use `mytimer` or `python -m mytimer` to run this program


### Version

```console
mytimer --version
```

### Basic

```console
Expand Down
13 changes: 8 additions & 5 deletions mytimer/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""mytimer main."""
from mytimer.functions import countdown_timer, countup_timer
from mytimer.functions import countdown_timer, countup_timer, MY_TIMER_VERSION
import argparse


Expand All @@ -22,15 +22,18 @@ def main():
const=1)
parser.add_argument('--countup', help='countup timer', nargs="?", const=1)
parser.add_argument('--alarm', help='alarm', nargs="?", const=1)
parser.add_argument('--version', help='version', nargs="?", const=1)
args = parser.parse_args()
for item in params:
if getattr(args, item) is not None:
params[item] = getattr(args, item)
if args.countdown:
countdown_timer(**params)
if args.version:
print(MY_TIMER_VERSION)
else:
countup_timer(**params)

if args.countdown:
countdown_timer(**params)
else:
countup_timer(**params)

if __name__ == "__main__":
main()

0 comments on commit afb318f

Please sign in to comment.