Skip to content

Commit 73719e9

Browse files
authored
Merge pull request #50 from numary/feature/num-39
Add secret command
2 parents 7f20ee1 + 89aa07b commit 73719e9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ func Execute() {
198198
root.AddCommand(script_exec)
199199
root.AddCommand(script_check)
200200
root.AddCommand(version)
201+
root.AddCommand(stickersCmd)
201202

202203
if err := root.Execute(); err != nil {
203204
fmt.Fprintln(os.Stderr, err)

cmd/stickers.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os/exec"
7+
"runtime"
8+
"time"
9+
10+
"github.com/spf13/cobra"
11+
)
12+
13+
func open(url string) {
14+
var err error
15+
16+
switch runtime.GOOS {
17+
case "linux":
18+
err = exec.Command("xdg-open", url).Start()
19+
case "windows":
20+
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
21+
case "darwin":
22+
err = exec.Command("open", url).Start()
23+
default:
24+
fmt.Printf("you should head to: %s\n", url)
25+
}
26+
27+
if err != nil {
28+
log.Fatal(err)
29+
}
30+
}
31+
32+
var stickersCmd = &cobra.Command{
33+
Use: "stickers",
34+
Run: func(cmd *cobra.Command, args []string) {
35+
token := fmt.Sprintf("cli-%d", time.Now().Unix())
36+
url := fmt.Sprintf("https://airtable.com/shrp41dAnjv0LSlxW?prefill_Token=%s", token)
37+
38+
fmt.Printf("You found a very special sub-command...\n\n")
39+
fmt.Printf("Hit Enter to continue\n\n")
40+
fmt.Scanln()
41+
open(url)
42+
},
43+
}

0 commit comments

Comments
 (0)