Skip to content

Commit

Permalink
Improved clipboard autocomplete (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbgf authored Nov 27, 2024
2 parents c8a0724 + 6ce4586 commit 5830088
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 187 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb # v4.2.2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: stable

- uses: anchore/sbom-action/download-syft@v0.17.8
- uses: sigstore/cosign-installer@v3.7.0
- uses: anchore/sbom-action/download-syft@55dc4ee22412511ee8c3142cbea40418e6cec693 # v0.17.8
- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
distribution: goreleaser
version: '~> v2'
Expand All @@ -40,6 +40,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Attest release artefacts
uses: actions/attest-build-provenance@v1
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
with:
subject-path: "dist/qubesome*"
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb # v4.2.2

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: stable

Expand Down
30 changes: 27 additions & 3 deletions .obs/workflows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
workflow:
version: '1.1'
testbuild:
steps:
- branch_package:
source_project: devel:languages:go
source_project: home:pjbgf:branches:devel:languages:go
source_package: qubesome
target_project: home:pjbgf
target_project: home:pjbgf:ci:devel:languages:go
add_repositories: disable
- configure_repositories:
project: home:pjbgf:ci:devel:languages:go
repositories:
- name: openSUSE_Factory
paths:
- target_project: home:pjbgf:branches:devel:languages:go
target_repository: openSUSE_Factory
architectures:
- x86_64
- aarch64
filters:
event: pull_request

rebuild:
steps:
- trigger_services:
project: home:pjbgf:branches:devel:languages:go
package: qubesome
filters:
event: push
branches:
only:
- main
24 changes: 24 additions & 0 deletions cmd/cli/clipboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ qubesome clip from-host -profile <name> - Copy clipboard contents from ho
Flags: []cli.Flag{
clipType,
},
ShellComplete: func(ctx context.Context, cmd *cli.Command) {
if cmd.NArg() > 0 {
return
}
for _, p := range activeProfiles() {
fmt.Println(p)
}
},
Action: func(ctx context.Context, c *cli.Command) error {
target, err := profileOrActive(targetProfile)
if err != nil {
Expand Down Expand Up @@ -88,6 +96,14 @@ qubesome clip from-host -profile <name> - Copy clipboard contents from ho
Flags: []cli.Flag{
clipType,
},
ShellComplete: func(ctx context.Context, cmd *cli.Command) {
if cmd.NArg() > 1 {
return
}
for _, p := range activeProfiles() {
fmt.Println(p)
}
},
Action: func(ctx context.Context, c *cli.Command) error {
cfg := profileConfigOrDefault(targetProfile)

Expand Down Expand Up @@ -136,6 +152,14 @@ qubesome clip to-host -profile <name> - Copy clipboard contents from a sp
Flags: []cli.Flag{
clipType,
},
ShellComplete: func(ctx context.Context, cmd *cli.Command) {
if cmd.NArg() > 0 {
return
}
for _, p := range activeProfiles() {
fmt.Println(p)
}
},
Action: func(ctx context.Context, c *cli.Command) error {
target, err := profileOrActive(sourceProfile)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions cmd/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,14 @@ func activeConfigs() []string {

return active
}

func activeProfiles() []string {
cfgs := activeConfigs()
profiles := make([]string, 0, len(cfgs))

for _, file := range cfgs {
profiles = append(profiles, strings.TrimSuffix(filepath.Base(file), ".config"))
}

return profiles
}
95 changes: 0 additions & 95 deletions internal/command/mocks.go

This file was deleted.

80 changes: 0 additions & 80 deletions internal/socket/socket.go

This file was deleted.

13 changes: 13 additions & 0 deletions internal/util/xauth/xauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,16 @@ func TestToNumeric(t *testing.T) {
})
}
}

func FuzzToNumberic(f *testing.F) {
f.Fuzz(func(t *testing.T, input []byte) {
ToNumeric(input)
})
}

func FuzzAuthPair(f *testing.F) {
f.Fuzz(func(t *testing.T, display uint8, parent []byte) {
_ = AuthPair(display, bytes.NewReader(parent),
&bytes.Buffer{}, &bytes.Buffer{})
})
}

0 comments on commit 5830088

Please sign in to comment.