Skip to content

Commit f52a922

Browse files
final naming fix and add add usage
1 parent 918cd83 commit f52a922

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
run: |
7979
cd dist
8080
zip json-to-sql-Linux.zip json-to-sql-Linux
81-
zip json-to-sql-macOs.zip json-to-sql-macOS
81+
zip json-to-sql-macOS.zip json-to-sql-macOS
8282
- name: Create GitHub Release
8383
uses: softprops/action-gh-release@v2
8484
with:

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,45 @@ Open terminal and run the following commands:
2020
curl -fsSL https://raw.githubusercontent.com/2002Bishwajeet/json-to-sql/main/setup.sh | bash
2121
```
2222

23+
## Usage
24+
25+
After installation, you can use the `json-to-sql` command to convert a JSON file to SQL. The basic usage is as follows:
26+
27+
```bash
28+
json-to-sql <file> [table] [--normalize] [dest]
29+
```
30+
31+
- `file`: The JSON file to convert.
32+
- `table`: (Optional) The table name for the SQL file. If not provided, the filename will be used.
33+
- `--normalize`: (Optional) Normalize the JSON data.
34+
- `dest`: (Optional) Destination path for the SQL file. If not provided, the current directory will be used.
35+
36+
### Examples
37+
38+
Convert a JSON file to SQL with default settings:
39+
40+
```bash
41+
json-to-sql data.json
42+
```
43+
44+
Convert a JSON file to SQL with a specified table name:
45+
46+
```bash
47+
json-to-sql data.json my_table
48+
```
49+
50+
Convert a JSON file to SQL with normalization:
51+
52+
```bash
53+
json-to-sql data.json --normalize
54+
```
55+
56+
Convert a JSON file to SQL and save the output to a specific directory:
57+
58+
```bash
59+
json-to-sql data.json my_table --normalize /path/to/output
60+
```
61+
2362
## Motivation
2463

2564
The motivation behind this project was to learn functional programming language and this was the best way for me. I chose to implement this project idea as I needed to get some base knowledge around parsers and improve the current online json2sql parsers we have on the web. I won't recommend this to use for complex jsons but for simple jsons, this should work fine.

app/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ main :: IO ()
8080
main = do
8181
start <- getCurrentTime
8282
args <- getArgs
83-
when (null args) $ error "Usage: json2sql -h for help"
83+
when (null args) $ error "Usage: json-to-sql -h for help"
8484
if head args == "-h" || head args == "--help"
8585
then do
86-
putStrLn "Usage: json2sql <file> [table] [--normalize] [dest]"
86+
putStrLn "Usage: json-to-sql <file> [table] [--normalize] [dest]"
8787
putStrLn "Options:"
8888
putStrLn " --normalize Normalize the JSON data"
8989
putStrLn " dest Destination path for the SQL file"

0 commit comments

Comments
 (0)