Skip to content

Commit

Permalink
Add completion command skeleton for outputting completion files in th…
Browse files Browse the repository at this point in the history
…eir respective directories
  • Loading branch information
dmhdeveloper committed Feb 2, 2024
1 parent b371f54 commit 2e19bbd
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 9 deletions.
8 changes: 4 additions & 4 deletions cmd/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"os"

"github.com/dmhdeveloper/config/command"
"github.com/dmhdeveloper/config/configs"
"github.com/dmhdeveloper/config/logger"
"github.com/dmhdeveloper/config/internal/cli"
"github.com/dmhdeveloper/config/internal/command"
"github.com/dmhdeveloper/config/internal/logger"
)

var (
Expand All @@ -23,7 +23,7 @@ func main() {
os.Exit(0)
}

conf, err := configs.LoadConfig()
conf, err := cli.LoadConfig()
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
Empty file added completion/bash_completion.sh
Empty file.
Empty file added completion/zsh_completion.zsh
Empty file.
2 changes: 1 addition & 1 deletion configs/config.go → internal/cli/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package configs
package cli

import (
"fmt"
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions internal/command/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package command

const (
bashBaseDir = "/usr/share/bash-completion/completions/"

Check failure on line 4 in internal/command/completion.go

View workflow job for this annotation

GitHub Actions / lint

const `bashBaseDir` is unused (unused)
zshBaseDir = "/usr/share/zsh/site-functions/"

Check failure on line 5 in internal/command/completion.go

View workflow job for this annotation

GitHub Actions / lint

const `zshBaseDir` is unused (unused)
)

type CompletionCmd struct{}

func NewCompletionCmd() CompletionCmd {
return CompletionCmd{}
}

func (c CompletionCmd) Run(args ...string) int {

Check failure on line 14 in internal/command/completion.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
return 0
}

func (c CompletionCmd) Help() string {
return ""
}
File renamed without changes.
8 changes: 4 additions & 4 deletions command/init.go → internal/command/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"os/exec"
"strings"

"github.com/dmhdeveloper/config/configs"
"github.com/dmhdeveloper/config/logger"
"github.com/dmhdeveloper/config/internal/cli"
"github.com/dmhdeveloper/config/internal/logger"
)

var (
Expand Down Expand Up @@ -53,11 +53,11 @@ func (i InitCmd) Run(args ...string) int {
return 1
}

conf := configs.CLIConfig{
conf := cli.CLIConfig{
GitDir: gitDir,
WorkTree: workTree,
}
_, err = configs.UpdateConfig(conf)
_, err = cli.UpdateConfig(conf)
if err != nil {
if debug {
i.log.Println(err)
Expand Down
File renamed without changes.

0 comments on commit 2e19bbd

Please sign in to comment.