Implement basic command structure
This commit is contained in:
parent
c48af21a49
commit
b4251237ba
17
Gosl.go
Normal file
17
Gosl.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package main // code.bitsetter.de/fun/gosl
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"code.bitsetter.de/fun/gosl/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Max out processor usage:
|
||||
// since go 1.5 it's the default to use all available cores,
|
||||
// let's stay compatible to go <= 1.4
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
// let each cmd handle itself
|
||||
cmd.Execute()
|
||||
}
|
22
cmd/Client.go
Normal file
22
cmd/Client.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package cmd // code.bitsetter.de/fun/gosl/cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var cmdClient = &cobra.Command{
|
||||
Use: "client",
|
||||
Short: "Runs Gosl as a client",
|
||||
Long: "Runs Gosl as a client",
|
||||
// Run:
|
||||
}
|
||||
|
||||
func runClient(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("running client ...")
|
||||
}
|
||||
|
||||
func init() {
|
||||
cmdClient.Run = runClient
|
||||
}
|
24
cmd/Cmd.go
Normal file
24
cmd/Cmd.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package cmd // code.bitsetter.de/fun/gosl/cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var cmdGosl = &cobra.Command{
|
||||
Use: "gosl [command]",
|
||||
Short: "Run a gosl instance",
|
||||
Long: `Run a gosl server or client."
|
||||
|
||||
For further instructions run 'gosl help [command]'
|
||||
`,
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
cmdGosl.AddCommand(cmdServer)
|
||||
cmdGosl.AddCommand(cmdClient)
|
||||
if err := cmdGosl.Execute(); err != nil {
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
22
cmd/Server.go
Normal file
22
cmd/Server.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package cmd // code.bitsetter.de/fun/gosl/cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var cmdServer = &cobra.Command{
|
||||
Use: "server",
|
||||
Short: "Runs Gosl as a server",
|
||||
Long: "Runs Gosl as a server",
|
||||
// Run:
|
||||
}
|
||||
|
||||
func runServer(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("running server ...")
|
||||
}
|
||||
|
||||
func init() {
|
||||
cmdServer.Run = runServer
|
||||
}
|
6
data/Screen.go
Normal file
6
data/Screen.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package data // code.bitsetter.de/fun/gosl/data
|
||||
|
||||
type Screen struct {
|
||||
w, h int
|
||||
data []rune
|
||||
}
|
Loading…
Reference in New Issue
Block a user