-
Notifications
You must be signed in to change notification settings - Fork 2
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
0 parents
commit cd5e9fc
Showing
21 changed files
with
510 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
|
||
[*.go] | ||
indent_style = tab | ||
insert_final_newline = false | ||
|
||
[Makefile] | ||
indent_style = tab |
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,24 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up env | ||
run: | | ||
VERSION=${GITHUB_REF_NAME#v} | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22 | ||
- name: Build | ||
run: make builds |
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,35 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up env | ||
run: | | ||
VERSION=${GITHUB_REF_NAME#v} | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22 | ||
- name: Set up golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.58 | ||
cache: true | ||
- name: Lint | ||
run: make lint |
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,29 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up env | ||
run: | | ||
VERSION=${GITHUB_REF_NAME#v} | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.22 | ||
cache: true | ||
- name: Build | ||
run: make builds | ||
- name: Release | ||
run: make release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,31 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up env | ||
run: | | ||
VERSION=${GITHUB_REF_NAME#v} | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22 | ||
- name: Test | ||
run: make test-coverage | ||
- name: Upload to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: true | ||
files: ./coverage.out | ||
name: codecov-umbrella |
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,21 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
.env | ||
http-client.env.json | ||
*.rest | ||
*.http | ||
|
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 mistweaver.co | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,29 @@ | ||
BIN_NAME=kulala-fmt | ||
|
||
build-windows-64: | ||
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w -X 'github.com/mistweaverco/kulala-fmt/cmd/kulalafmt.VERSION=$(VERSION)'" -o dist/windows/$(BIN_NAME).exe main.go | ||
build-linux-64: | ||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w -X 'github.com/mistweaverco/kulala-fmt/cmd/kulalafmt.VERSION=$(VERSION)'" -o dist/linux/$(BIN_NAME)-linux main.go | ||
build-macos-arm64: | ||
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-s -w -X 'github.com/mistweaverco/kulala-fmt/cmd/kulalafmt.VERSION=$(VERSION)'" -o dist/macos/$(BIN_NAME)-macos main.go | ||
|
||
builds: build-linux-64 build-macos-arm64 build-windows-64 | ||
|
||
lint: | ||
golangci-lint run | ||
|
||
test: | ||
if [ -n $(COLORS_ENABLED) ]; then gotest ./... ; else go test ./...; fi | ||
|
||
test-coverage: | ||
go test -race -covermode=atomic -coverprofile=coverage.out ./... | ||
|
||
release: | ||
gh release create --generate-notes v$(VERSION) dist/linux/$(BIN_NAME)-linux dist/macos/$(BIN_NAME)-macos dist/windows/$(BIN_NAME).exe | ||
|
||
build-and-install-local-debug: | ||
go build -ldflags "-X 'github.com/mistweaverco/kulala-fmt/cmd/kulalafmt.VERSION=development'" -o dist/$(BIN_NAME) main.go | ||
sudo mv dist/$(BIN_NAME) /usr/bin/$(BIN_NAME) | ||
|
||
run: | ||
go run -ldflags "-X 'github.com/mistweaverco/kulala-fmt/cmd/kulalafmt.VERSION=development'" main.go |
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,41 @@ | ||
<div align="center"> | ||
|
||
 | ||
|
||
# kulala-fmt | ||
|
||
[](https://golang.org) | ||
[](/~https://github.com/mistweaverco/kulala-fmt/releases/latest) | ||
[](https://discord.gg/QyVQmfY4Rt) | ||
|
||
[Install](#install) • [Usage](#usage) | ||
|
||
<p></p> | ||
|
||
An opinionated 🦄 .http and .rest 🐼 files linter 💄 and formatter ⚡. | ||
|
||
<p></p> | ||
|
||
</div> | ||
|
||
## Install | ||
|
||
Just grab the latest release: | ||
|
||
- [Linux](/~https://github.com/mistweaverco/kulala-fmt/releases/download/latest/kulala-fmt-linux) | ||
- [Mac](/~https://github.com/mistweaverco/kulala-fmt/releases/download/latest/kulala-fmt-macos) | ||
- [Windows](/~https://github.com/mistweaverco/kulala-fmt/releases/download/latest/kulala-fmt.exe) | ||
|
||
## Usage | ||
|
||
Format all `.http` and `.rest` files in the current directory and its subdirectories: | ||
|
||
```sh | ||
kulala-fmt | ||
``` | ||
|
||
Check if all `.http` and `.rest` files in the current directory and its subdirectories are formatted: | ||
|
||
```sh | ||
kulala-fmt --check | ||
``` |
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,19 @@ | ||
package kulalafmt | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var aboutCmd = &cobra.Command{ | ||
Use: "about", | ||
Short: "Shows information about kulala-fmt", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("Made with ❤️ by Marco Kellershoff - https://gorilla.moe") | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(aboutCmd) | ||
} |
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,36 @@ | ||
package kulalafmt | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/charmbracelet/log" | ||
"github.com/mistweaverco/kulala-fmt/internal/config" | ||
"github.com/mistweaverco/kulala-fmt/internal/parser" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var cfg = config.NewConfig(config.Config{}) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "kulala-fmt", | ||
Short: "An opinionated 🦄 .http and .rest 🐼 files linter 💄 and formatter ⚡.", | ||
Long: "Formats and lints .http and .rest files in the current directory and subdirectories.", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) == 0 { | ||
log.Info("Starting kulala-fmt 🦄", "version", VERSION) | ||
parser.Start(cfg.GetConfigFlags()) | ||
} | ||
}, | ||
} | ||
|
||
func Execute() { | ||
err := rootCmd.Execute() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func init() { | ||
rootCmd.PersistentFlags().BoolVar(&cfg.Flags.DryRun, "dry-run", false, "dry run") | ||
rootCmd.PersistentFlags().BoolVar(&cfg.Flags.Check, "check", false, "check") | ||
} |
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,22 @@ | ||
package kulalafmt | ||
|
||
import ( | ||
"runtime" | ||
|
||
"github.com/charmbracelet/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var VERSION string | ||
|
||
var versionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Print the version number of kulala-fmt", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
log.Info("Version", runtime.GOOS, VERSION) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(versionCmd) | ||
} |
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,2 @@ | ||
* | ||
!.gitignore |
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,24 @@ | ||
module github.com/mistweaverco/kulala-fmt | ||
|
||
go 1.22 | ||
|
||
require ( | ||
github.com/charmbracelet/log v0.4.0 | ||
github.com/spf13/cobra v1.8.0 | ||
) | ||
|
||
require ( | ||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect | ||
github.com/charmbracelet/lipgloss v0.10.0 // indirect | ||
github.com/go-logfmt/logfmt v0.6.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mattn/go-runewidth v0.0.15 // indirect | ||
github.com/muesli/reflow v0.3.0 // indirect | ||
github.com/muesli/termenv v0.15.2 // indirect | ||
github.com/rivo/uniseg v0.4.7 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect | ||
golang.org/x/sys v0.20.0 // indirect | ||
) |
Oops, something went wrong.