Skip to content

Commit

Permalink
setup pyproject
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Jun 26, 2024
1 parent 2fa9a28 commit e85f756
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyv }}
- name: Test main.py
- name: Test src/main.py
run: |
python ./main.py
python src/main.py
- name: Test cli.py
shell: bash
run: |
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ convert Ezon gpx files

## Usage

### Python
### Source

see [./main.py](./main.py#L141)
#### Python

### CLI
see [./src/main.py](./src/main.py#L141)

#### CLI

```bash
./cli.py test/test.gpx [path]
./src/cli.py test/test.gpx [path]
```

```bash
./cli.py --help
./src/cli.py --help
```

## Develop Env
Expand Down
45 changes: 0 additions & 45 deletions cli.py

This file was deleted.

16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "ezon-gpx"
version = "0.1.0"
authors = [
{name = "Uiolee"},
]
readme = "README.md"
license = {text = "MPL-2.0"}

[project.scripts]
ezon-gpx = "cli:cli"

45 changes: 45 additions & 0 deletions src/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import argparse
from os import listdir
from os.path import join, isdir

from main import convert


def cli():
parser = argparse.ArgumentParser(prog="ezon-gpx")

parser.add_argument(
"path",
nargs="+",
)
parser.add_argument("-o", "--out", help="the filename of output")
parser.add_argument(
"-d", "--dir", help="the dest dir of output", type=str, default="dist"
)
parser.add_argument("--hour", help="hour offset", type=int, default=-8)
parser.add_argument(
"--indent", help="output file with indent", type=bool, default=False
)
parser.add_argument("--strict", help="strict", type=bool, default=False)
args = parser.parse_args()

print()
print("====== ezon-gpx cli ======")
print(args)

paths = []
for path in args.path:
if path.endswith(".gpx"):
paths.append(path)
elif isdir(path):
for p in listdir(path):
if p.endswith(".gpx"):
paths.append(join(path, p))

for path in paths:
print()
print("[cli.py]", "processing", path)
convert(path, args.out, args.dir, args.hour, args.indent, args.strict)

print()
print("[cli.py]", "processed files:", len(paths))
File renamed without changes.
2 changes: 1 addition & 1 deletion test/cli.test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

python cli.py test
python src/cli.py test

0 comments on commit e85f756

Please sign in to comment.