Skip to content

Commit

Permalink
reorginization and basic cli
Browse files Browse the repository at this point in the history
  • Loading branch information
solipsis committed Feb 20, 2018
1 parent 20657c1 commit 90947c9
Show file tree
Hide file tree
Showing 18 changed files with 298 additions and 1,193 deletions.
22 changes: 22 additions & 0 deletions cmd/changePin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"log"

"github.com/spf13/cobra"
)

func init() {
rootCmd.AddCommand(changePinCmd)
}

var changePinCmd = &cobra.Command{
Use: "changePin",
Short: "Change or add a pin to the device",
Long: "Change or add a pin to the device",
Run: func(cmd *cobra.Command, args []string) {
if err := kk.ChangePin(); err != nil {
log.Fatal(err)
}
},
}
23 changes: 20 additions & 3 deletions cmd/ping.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
package cmd

import "fmt"
import (
"log"

func main() {
fmt.Println("vim-go")
"github.com/spf13/cobra"
)

func init() {
rootCmd.AddCommand(pingCmd)
}

var pingCmd = &cobra.Command{
Use: "ping",
Short: "Ping the device with a message",
Long: `Ping the device with a message and optionally,
display it on the device.`,
Run: func(cmd *cobra.Command, args []string) {
_, err := kk.Ping("butt", true, true, true)
if err != nil {
log.Fatal(err)
}
},
}
1 change: 1 addition & 0 deletions cmd/removePin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package cmd
41 changes: 41 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cmd

import (
"fmt"
"log"
"os"

"github.com/solipsis/go-keepkey/pkg/keepkey"
"github.com/spf13/cobra"
)

var kk *keepkey.Keepkey

func init() {
cobra.OnInitialize(connectDevice)
}

func connectDevice() {
var err error
kk, err = keepkey.GetDevice()
if err != nil {
log.Fatal(err)
}
}

var rootCmd = &cobra.Command{
Use: "go-keepkey",
Short: "go-keepkey blah short description",
Long: "long",
Run: func(cmd *cobra.Command, args []string) {

fmt.Println("how does this work")
},
}

func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
Binary file added go-keepkey
Binary file not shown.
Loading

0 comments on commit 90947c9

Please sign in to comment.