6
6
"fmt"
7
7
"log"
8
8
"net/http"
9
+ "net/url"
9
10
"os"
10
11
11
12
"github.com/tj/kingpin"
@@ -17,7 +18,7 @@ var version = "0.0.1"
17
18
// endpoint for polls.
18
19
var endpoint = "https://m131jyck4m.execute-api.us-west-2.amazonaws.com/prod"
19
20
20
- // TODO: move this stuff to some client lib.
21
+ // TODO: move all this stuff into a pkg
21
22
type input struct {
22
23
Options []string `json:"body"`
23
24
}
@@ -37,6 +38,8 @@ func main() {
37
38
38
39
switch kingpin .MustParse (app .Parse (os .Args [1 :])) {
39
40
case create .FullCommand ():
41
+ // TODO: move all this stuff into a pkg
42
+
40
43
b , err := json .Marshal (input {Options : * options })
41
44
if err != nil {
42
45
log .Fatalf ("error marshaling: %s" , err )
@@ -53,6 +56,16 @@ func main() {
53
56
log .Fatalf ("error unmarshaling resonse: %s" , err )
54
57
}
55
58
56
- fmt .Println (out .ID )
59
+ for _ , o := range * options {
60
+ fmt .Println (link (out .ID , o ))
61
+ }
57
62
}
58
63
}
64
+
65
+ func link (id , option string ) string {
66
+ return fmt .Sprintf (`[%s](https://m131jyck4m.execute-api.us-west-2.amazonaws.com/prod/poll/%s/%s/vote)` , image (id , option ), id , url .PathEscape (option ))
67
+ }
68
+
69
+ func image (id , option string ) string {
70
+ return fmt .Sprintf (`` , id , url .PathEscape (option ))
71
+ }
0 commit comments