Skip to content

Commit a436b96

Browse files
committed
initial commit
0 parents  commit a436b96

File tree

20 files changed

+728
-0
lines changed

20 files changed

+728
-0
lines changed

.github/FUNDING.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
github: [rsteube]
4+
polar: carapace-sh
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Bug
2+
description: File a bug/issue
3+
title: "<title>"
4+
labels: [bug, fund]
5+
body:
6+
- type: textarea
7+
attributes:
8+
label: Current Behavior
9+
description: A concise description of what you're experiencing.
10+
validations:
11+
required: false
12+
- type: textarea
13+
attributes:
14+
label: Expected Behavior
15+
description: A concise description of what you expected to happen.
16+
validations:
17+
required: false
18+
- type: textarea
19+
attributes:
20+
label: Steps To Reproduce
21+
description: Steps to reproduce the behavior.
22+
placeholder: |
23+
1. In this environment...
24+
2. With this config...
25+
3. Run '...'
26+
4. See error...
27+
validations:
28+
required: false
29+
- type: input
30+
attributes:
31+
label: Version
32+
description: Version where this occured.
33+
validations:
34+
required: false
35+
- type: textarea
36+
attributes:
37+
label: Anything else?
38+
description: |
39+
Links? References? Anything that will give us more context about the issue you are encountering!
40+
41+
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
42+
validations:
43+
required: false
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Request
2+
description: Submit a request
3+
title: "<title>"
4+
labels: [enhancement, fund]
5+
body:
6+
- type: textarea
7+
attributes:
8+
label: Request
9+
description: Describe the feature or problem you’d like to solve.
10+
validations:
11+
required: false
12+
- type: textarea
13+
attributes:
14+
label: Proposed solution
15+
description: How will it benefit the project and its users.
16+
validations:
17+
required: false
18+
- type: textarea
19+
attributes:
20+
label: Anything else?
21+
description: |
22+
Links? References? Anything that will give us more context about the request!
23+
24+
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
25+
validations:
26+
required: false

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
8+
- package-ecosystem: "gomod"
9+
directory: "/cmd"
10+
schedule:
11+
interval: "daily"
12+
13+
- package-ecosystem: "github-actions"
14+
directory: "/"
15+
schedule:
16+
interval: "daily"

.github/workflows/go.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Go
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
container: ghcr.io/carapace-sh/go:1.23.1
11+
steps:
12+
- name: shallow clone
13+
uses: actions/checkout@v4
14+
if: "!startsWith(github.ref, 'refs/tags/')"
15+
16+
- name: deep clone
17+
uses: actions/checkout@v4
18+
if: startsWith(github.ref, 'refs/tags/')
19+
with:
20+
fetch-depth: 0
21+
22+
- name: fix git safe.directory
23+
run: git config --global --add safe.directory '*'
24+
25+
- name: Build
26+
run: go build -v ./...
27+
28+
- name: Test
29+
run: go test -v -coverprofile=profile.cov ./...
30+
31+
- name: "Check formatting"
32+
run: '[ "$(gofmt -d -s . | tee -a /dev/stderr)" = "" ]'
33+
34+
- uses: shogo82148/actions-goveralls@v1
35+
with:
36+
path-to-profile: profile.cov
37+
38+
- name: "staticcheck"
39+
run: go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck ./...
40+
41+
- name: Run GoReleaser
42+
uses: goreleaser/goreleaser-action@v6
43+
if: startsWith(github.ref, 'refs/tags/')
44+
with:
45+
version: latest
46+
args: release --clean
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
AUR_KEY: ${{ secrets.AUR_KEY }}
50+
GORELEASER_GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: 2
2+
before:
3+
hooks:
4+
- go mod download
5+
builds:
6+
- id: default
7+
env:
8+
- CGO_ENABLED=0
9+
goos:
10+
- linux
11+
- windows
12+
- darwin
13+
main: ./cmd/carapace-selfupdate
14+
binary: carapace-selfupdate
15+
- id: termux
16+
env:
17+
- CGO_ENABLED=1
18+
goos:
19+
- android
20+
goarch:
21+
- amd64
22+
- arm64
23+
- arm
24+
- "386"
25+
main: ./cmd/carapace-selfupdate
26+
binary: carapace-selfupdate
27+
gobinary: go-termux
28+
archives:
29+
- id: default
30+
builds:
31+
- default
32+
format_overrides:
33+
- goos: windows
34+
format: zip
35+
- id: termux
36+
builds:
37+
- termux
38+
name_template: '{{ .Binary }}_{{ .Version }}_termux_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
39+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 rsteube
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# carapace-selfupdate

checksum.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package selfupdate
2+
3+
import (
4+
"crypto/sha256"
5+
"io"
6+
"os"
7+
)
8+
9+
//lint:ignore U1000 TODO
10+
func verify(path string) error {
11+
f, err := os.Open(path)
12+
if err != nil {
13+
return err
14+
}
15+
defer f.Close()
16+
17+
h := sha256.New()
18+
if _, err := io.Copy(h, f); err != nil {
19+
return err
20+
}
21+
return nil
22+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package cmd
2+
3+
import (
4+
"github.com/carapace-sh/carapace"
5+
selfupdate "github.com/carapace-sh/carapace-selfupdate"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
var rootCmd = &cobra.Command{
10+
Use: "carapace-selfupdate",
11+
Short: "",
12+
Run: func(cmd *cobra.Command, args []string) {},
13+
}
14+
15+
func Execute(version string) error {
16+
rootCmd.Version = version
17+
return rootCmd.Execute()
18+
}
19+
func init() {
20+
carapace.Gen(rootCmd).Standalone()
21+
22+
cmd := selfupdate.Command("carapace-sh", "carapace-bin", selfupdate.WithBinary("carapace"))
23+
cmd.Use = "carapace"
24+
rootCmd.AddCommand(cmd)
25+
26+
cmd = selfupdate.Command("carapace-sh", "carapace-bridge")
27+
cmd.Use = "bridge"
28+
rootCmd.AddCommand(cmd)
29+
30+
cmd = selfupdate.Command("carapace-sh", "carapace-shlex")
31+
cmd.Use = "shlex"
32+
rootCmd.AddCommand(cmd)
33+
34+
cmd = selfupdate.Command("carapace-sh", "carapace-spec")
35+
cmd.Use = "spec"
36+
rootCmd.AddCommand(cmd)
37+
38+
}

0 commit comments

Comments
 (0)