Skip to content

Commit a5a7046

Browse files
committed
adding cli
1 parent 691323e commit a5a7046

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Assuming you have a directory structure like this:
1616
You can query the JSON files using SQL syntax. For example, to get all users from the `users` file, you can run:
1717

1818
```sh
19-
json_sql "select * from users"
19+
abstra-json-sql "select * from users"
2020
```
2121

2222
This will return all the users in the `users.json` file.

json_sql/cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def print_result(result: List[dict], format: Literal["json", "csv"]):
2828
writer.writerow(row)
2929

3030

31-
if __name__ == "__main__":
31+
def main():
3232
parser = ArgumentParser(description="Run SQL queries on JSON files.")
3333
parser.add_argument("--code", type=str, help="SQL query to execute", default=None)
3434
parser.add_argument(
@@ -74,3 +74,7 @@ def print_result(result: List[dict], format: Literal["json", "csv"]):
7474
except Exception as e:
7575
print(f"Error: {e}")
7676
continue
77+
78+
79+
if __name__ == "__main__":
80+
main()

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@
3939
url="https://github.com/abstra-app/json-sql",
4040
packages=find_packages(exclude=["tests"]),
4141
install_requires=REQUIREMENTS,
42+
entry_points={
43+
"console_scripts": [
44+
"abstra_json_sql=abstra_json_sql.cli:main",
45+
],
46+
},
4247
)

0 commit comments

Comments
 (0)