-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
775 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.2.1' | ||
__version__ = '0.3.0' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
YW := '\033[0;33m' | ||
RD := '\033[0;31m' | ||
LC := '\033[0;36m' | ||
LB := '\033[0;34m' | ||
LG := '\033[0;32m' | ||
NC := '\033[0m' | ||
|
||
# just --list | ||
default: | ||
@just --list --unsorted | ||
|
||
# poetry pass thru command | ||
po *args: | ||
poetry run {{args}} | ||
|
||
# pass thru | ||
blank *args: | ||
{{args}} | ||
|
||
# INFO: develop, build, deploy | ||
info: | ||
@echo | ||
@echo " {{LC}}Workflow to develop python scripts and deploy to homebrew.{{LG}}" | ||
@echo | ||
@echo " {{LG}}1.{{NC}} Develop/commit on dev" | ||
@echo " {{LG}}2.{{NC}} just test" | ||
@echo " {{LG}}3.{{NC}} just bump" | ||
@echo " {{LG}}4.{{NC}} git checkout -b release/0.3.1" | ||
@echo " * final TESTS and debug" | ||
@echo " * git push --set-upstream origin release/0.3.1" | ||
@echo " * PR 'release/0.3.1' for CI/CD tests (click link to open PR)" | ||
@echo " * merge to main" | ||
@echo " * tag" | ||
@echo " {{LG}}5.{{NC}} release to homebrew repo on merge to main" | ||
|
||
|
||
# ptpython REPL in poetry shell | ||
repl: | ||
@poetry run ptpython | ||
|
||
# instructions to bump version number | ||
bump: | ||
@echo | ||
@echo " {{LC}}REMINDER:{{NC}} You need to manually bump the version numbers in these locations." | ||
@echo " ./desertislandutils/" | ||
@echo " {{YW}}__init__.py" | ||
@echo " pyproject.toml" | ||
@echo " tests/test_desertislandutils.py" | ||
code __init__.py pyproject.toml tests/test_desertislandutils.py | ||
|
||
# pytest | ||
test *args: | ||
@echo | ||
@echo " ✙✙✙✙✙✙✙✙ TESTING ✙✙✙✙✙✙✙✙" | ||
poetry run pytest --disable-warnings --verbose {{args}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# WN: Week Number | ||
I need to know the ISO reporting week for the current date all the time. And I like to be able to get the week number for any arbitrary date, usually this is in SQL but a CLI script also good. | ||
|
||
This has been working fine in bash for years, but time to thaw out my python package development. | ||
Also, its time to incorporate `justfile` into my package development workflow, so much easier to document commands that way. | ||
|
||
Typer is pretty sweet, waaay beyond Argparse. | ||
|
||
## REQUIREMENTS | ||
Options: | ||
input date, default current date | ||
Week ending day, default saturday (ISO minus 1) | ||
|
||
Dependencies: | ||
[Typer CLI package instead of ArgParse](https://typer.tiangolo.com/tutorial/first-steps/) | ||
Pendulum date package | ||
Just -- yes tis time | ||
|
||
## CHEWS PLACE | ||
```sh | ||
poetry env use 3.11 | ||
poetry add "typer[all]" | ||
poetry add pendulum="~2.0" | ||
# note pendulum 2.1.2 kept failing build, I went through this before | ||
poetry install | ||
|
||
# add script name to pyproject: | ||
[tool.poetry.scripts] | ||
wn = "src.weeknumber.wn:app" | ||
``` | ||
|
||
At this point I can try the app: | ||
```sh | ||
poetry shell | ||
(desertislandutils-py3.11) $> wn --help | ||
``` | ||
actually its expecting a command, gotta figure single command app. | ||
|
||
## TEARS IN RAIN | ||
**It works great!** | ||
|
||
```sh | ||
wn --help | ||
|
||
Usage: wn [OPTIONS] [DATE] | ||
|
||
ISO year week number of a date as YYYY-WDD. Default weekend day is Sat. | ||
Example: | ||
$> wn 'Jul 22' | ||
2023-W29 | ||
|
||
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ | ||
│ date [DATE] A text expression of date, ex: 'November 27', or 2112-07-29 [default: (dynamic)] │ | ||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ | ||
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ | ||
│ --sunday Weekend is Saturday by default, this flag sets Sunday weekend day. │ | ||
│ --last Give week number of most recently completed week (overrides DATE argument). │ | ||
│ --verbose --no-verbose [default: no-verbose] │ | ||
│ --install-completion Install completion for the current shell. │ | ||
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │ | ||
│ --help Show this message and exit. │ | ||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ | ||
|
||
wn 2112-07-24 --sunday --verbose | ||
# Input date string: 2112-07-24 | ||
# Timezone: US/Pacific | ||
# Parsed date: 2112-07-24 | ||
# ISO week number: | ||
# 2112-W29 | ||
|
||
wn 2112-07-24 --verbose | ||
# Input date string: 2112-07-24 | ||
# Timezone: US/Pacific | ||
# Parsed date: 2112-07-24 | ||
# ISO week number: | ||
# 2112-W30 | ||
|
||
wn 2112-07-24 | ||
# 2112-W30 | ||
|
||
wn --last | ||
# 2023-W48 | ||
``` | ||
|
||
## TEST | ||
* its a cli service that echoes to stdout | ||
* use `capsys` fixture as in `test_wn` to compare outputs to expected | ||
|
||
```sh | ||
just test tests/wn | ||
|
||
✙✙✙✙✙✙✙✙ TESTING ✙✙✙✙✙✙✙✙ | ||
poetry run pytest --disable-warnings --verbose tests/wn | ||
========================================================= test session starts ========================================================== | ||
rootdir: /Users/merlinr/repo/the-others/desertislandutils | ||
collected 1 item | ||
tests/wn/test_wn.py::test_wn_options PASSED [100%] | ||
``` |
Oops, something went wrong.