Skip to content

Commit

Permalink
Fix cli bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RealAlexandreAI committed Jul 13, 2024
1 parent 3cc8f74 commit 83dd2dd
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 34 deletions.
9 changes: 7 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report---.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@ labels: bug
---

## Describe the bug

A clear and concise description of what the bug is.

### Steps to reproduce

Steps to reproduce the behavior.

### Expected behavior

A clear and concise description of what you expected to happen.

### Environment
- OS: [e.g. Arch Linux]
- Other details that you think may affect.

- OS: [e.g. Arch Linux]
- Other details that you think may affect.

### Additional context

Add any other context about the problem here.
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request---.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ labels: enhancement
---

## Summary

Brief explanation of the feature.

### Basic example

Include a basic example or links here.

### Motivation

Why are we doing this? What use cases does it support? What is the expected outcome?
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
types: [ opened, synchronize, reopened ]

jobs:
build:
Expand All @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: ['1.21', '1.22']
go-version: [ '1.21', '1.22' ]
env:
VERBOSE: 1

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main
- master
pull_request:
types: [opened, synchronize, reopened]
types: [ opened, synchronize, reopened ]

permissions:
contents: read
Expand All @@ -16,8 +16,8 @@ jobs:
golangci:
strategy:
matrix:
go: ['1.21', '1.22']
os: [macos-latest]
go: [ '1.21', '1.22' ]
os: [ macos-latest ]
name: lint
runs-on: ${{ matrix.os }}
steps:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,51 @@
## v0.0.5

### Improvements

- Tuning goreleaser, remove draft
- UT action
- Change minimal Go version

## v0.0.4

### New Features

- Add Homebrew tap.

## v0.0.3

### New Features

- Introduced `jsonrepair` as a command-line interface for easier use.

### Improvements

- Initialized `goreleaser` to streamline the release process.

### Bug Fixes

- Resolved an issue reported in upstream repository (#26).

## v0.0.2

### New Features

- Implemented `markerRecord` to enhance the tracking of nested data structures.

### Bug Fixes

- Addressed a bug identified in the upstream repository (#24).

### Deprecations

- (This section is left empty as there are no items to be removed in this release.)

## v0.0.1

### Initial Release

- Launched the initial version of `json-repair`, a tool designed to fix malformed JSON files.

### Deprecations

- (This section is left empty as there are no items to be removed in this initial release.)
52 changes: 37 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<img src="images/logo.png" alt="Logo" width="80" height="80">
</a>

<h3 align="center">json-repair</h3>
<h3 align="center">json-repair</h3>

<p align="center">
JSON Repair: Solution for JSON Anomalies from LLMs.
Expand All @@ -47,21 +47,23 @@


<!-- ABOUT THE PROJECT -->

## 🔧 Repair JSON! Solution for JSON Anomalies from LLMs

Welcome to the json-repair, your go-to solution for fixing those pesky JSON anomalies that can sidetrack your Large Language Model (LLM) processes. Our toolkit is designed to be the Swiss Army knife for all your JSON repair needs.
Welcome to the json-repair, your go-to solution for fixing those pesky JSON anomalies that can sidetrack your Large
Language Model (LLM) processes. Our toolkit is designed to be the Swiss Army knife for all your JSON repair needs.

### 🎯 Why Choose JSON Repair?

- 🏎️ GO Compatibility: Our library ensures a seamless experience for Go developers with its excellent compatibility.
- 🔗 Zero Dependencies: We've crafted a tool with zero external dependencies, keeping it lean and mean.
- 📚 Rich Test Cases: Benefit from a comprehensive suite of test cases that ensure reliability and accuracy.
- 🤖 Auto-Detection & Repair: Intelligently identifies and corrects a wide range of JSON errors, from syntax to structural issues.
- 🤖 Auto-Detection & Repair: Intelligently identifies and corrects a wide range of JSON errors, from syntax to
structural issues.
- 📐 Terminal CLI Support: The feature can also be used in the command-line and can be chained with command pipes.
- ⚙️ No Anxiety About Error: json-repair always gives the string result.
- 🌐 Open Source: Join a vibrant community of developers contributing to the ongoing evolution of the toolkit.


### 🔍 Supported Broken LLM JSON Output

- Single quote `"`
Expand All @@ -84,21 +86,22 @@ Welcome to the json-repair, your go-to solution for fixing those pesky JSON anom
- Incorrect key-value pair `{"key":"",}`
- etc.


<p align="right">(<a href="#readme-top">back to top</a>)</p>


<!-- GETTING STARTED -->

## 🏁 Getting Started

To add the JSON Repair to your Go project, use the following command:

```shell
go get github.com/RealAlexandreAI/json-repair
```

<!-- USAGE EXAMPLES -->
## Usage

## Usage

```go
package main
Expand All @@ -117,15 +120,17 @@ func main() {
}
```

> Additionally, there is `MustRepairJSON` for scenarios that are not suitable for error handling, such as pipes and trusted environments
> Additionally, there is `MustRepairJSON` for scenarios that are not suitable for error handling, such as pipes and
> trusted environments
_For more examples, please refer to the [Test Cases](https://github.com/RealAlexandreAI/json-repair/blob/master/main_test.go) Or <a href="https://goplay.tools/snippet/zyLfsLcsTwg">Online Playground</a>_
_For more examples, please refer to
the [Test Cases](https://github.com/RealAlexandreAI/json-repair/blob/master/main_test.go)
Or <a href="https://goplay.tools/snippet/zyLfsLcsTwg">Online Playground</a>_

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Terminal CLI


```bash

brew install realalexandreai/tap-jsonrepair/jsonrepair
Expand All @@ -138,10 +143,12 @@ jsonrepair -i "{'employees':['John', 'Anna', "
jsonrepair -f <json-file>.json
```

_You can also download binary from Release, please refer to the [Releases](https://github.com/RealAlexandreAI/json-repair/releases)._
_You can also download binary from Release, please refer to
the [Releases](https://github.com/RealAlexandreAI/json-repair/releases)._


<!-- ROADMAP -->

## Roadmap

- [x] Convert project from Python
Expand All @@ -152,18 +159,22 @@ _You can also download binary from Release, please refer to the [Releases](https
- [x] Add Homebrew tap
- [ ] Support Full-width character detection

See the [open issues](https://github.com/RealAlexandreAI/json-repair/issues) for a full list of proposed features (and known issues).
See the [open issues](https://github.com/RealAlexandreAI/json-repair/issues) for a full list of proposed features (and
known issues).

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- CONTRIBUTING -->

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any
contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also
simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!

1. Fork the Project
Expand All @@ -174,13 +185,12 @@ Don't forget to give the project a star! Thanks again!

<p align="right">(<a href="#readme-top">back to top</a>)</p>


## Related Project

- [python json_repair](https://github.com/mangiucugna/json_repair) - Inspiration of json-repair.


<!-- LICENSE -->

## License

Distributed under the GPLv3 License. See `LICENSE` for more information.
Expand All @@ -190,6 +200,7 @@ Distributed under the GPLv3 License. See `LICENSE` for more information.


<!-- CONTACT -->

## Contact

RealAlexandreAI - [@RealAlexandreAI](https://twitter.com/RealAlexandreAI)
Expand All @@ -201,14 +212,25 @@ Project Link: [https://github.com/RealAlexandreAI/json-repair](https://github.co

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->

[contributors-shield]: https://img.shields.io/github/contributors/RealAlexandreAI/json-repair.svg?style=for-the-badge

[contributors-url]: https://github.com/RealAlexandreAI/json-repair/graphs/contributors

[forks-shield]: https://img.shields.io/github/forks/RealAlexandreAI/json-repair.svg?style=for-the-badge

[forks-url]: https://github.com/RealAlexandreAI/json-repair/network/members

[stars-shield]: https://img.shields.io/github/stars/RealAlexandreAI/json-repair.svg?style=for-the-badge

[stars-url]: https://github.com/RealAlexandreAI/json-repair/stargazers

[issues-shield]: https://img.shields.io/github/issues/RealAlexandreAI/json-repair.svg?style=for-the-badge

[issues-url]: https://github.com/RealAlexandreAI/json-repair/issues

[license-shield]: https://img.shields.io/github/license/RealAlexandreAI/json-repair.svg?style=for-the-badge

[license-url]: https://github.com/RealAlexandreAI/json-repair/blob/master/LICENSE

[product-screenshot]: images/screenshot.png
20 changes: 8 additions & 12 deletions cli/jsonrepair-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package main
import (
"flag"
"fmt"
"os"

"github.com/RealAlexandreAI/json-repair"
"os"
)

const AppVersion = "0.0.8"
const AppVersion = "0.0.11"

var (
versionFlag bool
Expand Down Expand Up @@ -52,22 +51,19 @@ func main() {
return
}

if input != "" {
switch {
case input != "":
fmt.Println(jsonrepair.MustRepairJSON(input))
}

if file != "" {

if input != "" {
fmt.Println("---")
}

case file != "":
fi, err := os.ReadFile(file)
if err != nil {
fmt.Printf("[json-repair] invalid file path: %s", file)
fmt.Println()
return
}
fmt.Println(jsonrepair.MustRepairJSON(string(fi)))
default:
fmt.Println("{}")
}

}

0 comments on commit 83dd2dd

Please sign in to comment.