Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Init gnopls cmd using spf13/cobra
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Sep 22, 2023
1 parent 07d02eb commit c13556d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cmd
import (
"fmt"
"log/slog"
"os"
"github.com/spf13/cobra"
)

func GnoplsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "gnopls",
Short: `Gno Please! is a Gno language server`,
DisableSuggestions: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
slog.Info("Initializing Server...")

return nil
},
}

cmd.CompletionOptions.DisableDefaultCmd = true

return cmd
}

func Execute() {
if err := GnoplsCmd().Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ module github.com/harry-hov/gnopls

go 1.21.1

require (
github.com/spf13/cobra v1.5.0
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/harry-hov/gnopls/cmd"

func main() {
cmd.Execute()
}

0 comments on commit c13556d

Please sign in to comment.