Skip to content

Commit

Permalink
updated the doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sibis committed Aug 18, 2020
1 parent 8b0564c commit d6eb2ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
12 changes: 6 additions & 6 deletions cmd/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
var codeCmd = &cobra.Command{
Use: "code",
Short: "Authorize the application from your account",
Long: `Helps to generate the code by providing the access, we promise not to pose without your consent`,
Long: `Helps to generate the code by providing the access, we promise not to post anything from your account`,
Run: func(cmd *cobra.Command, args []string) {

path, _ := os.LookupEnv("HOME")
Expand All @@ -52,7 +52,7 @@ var codeCmd = &cobra.Command{
request.Header.Add("Accept", "application/json")
request.Header.Add("Host", "api.producthunt.com")
request.Header.Add("Content-Type", "application/json")
client := &http.Client{Timeout: time.Second * 30}
client := &http.Client{Timeout: time.Second * 60}
response, err := client.Do(request)
s.Stop()
if err != nil {
Expand All @@ -64,11 +64,11 @@ var codeCmd = &cobra.Command{
// Unmarshal or Decode the JSON to the interface.
json.Unmarshal([]byte(data), &result)
if result["access_token"] == nil {
fmt.Println("Please signin again to generate the fresh code by running, `producthunt signin`")
fmt.Println("Please signin again to generate the fresh code by running, `producthunt-cli signin`")
} else {
_, _ = f.WriteString(fmt.Sprintf("%s", result["access_token"]))
fmt.Println("Authenticated successfully!")
}

_, _ = f.WriteString(fmt.Sprintf("%s", result["access_token"]))
fmt.Println("Code added successfully!")
},
}

Expand Down
7 changes: 4 additions & 3 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cmd
import (
"encoding/json"
"fmt"
"strconv"

"../utils"
"github.com/mgutz/ansi"
Expand Down Expand Up @@ -56,8 +57,8 @@ type PostsJson struct {
// signinCmd represents the signin command
var listCmd = &cobra.Command{
Use: "list",
Short: "Fetches the list of products trnding",
Long: `current trending products`,
Short: "Fetches the list of trending products",
Long: `current trending products on Product Hunt app`,
Run: func(cmd *cobra.Command, args []string) {
jsonData := map[string]string{
"query": `
Expand Down Expand Up @@ -118,7 +119,7 @@ var listCmd = &cobra.Command{
productCategory += fmt.Sprintf("%s", category.Node.Name)
}
productCategory += " ]"
fmt.Print("👉 " + productName(product.Node.Name) + " (↑" + string(product.Node.VotesCount) + ") " + categoryColor(productCategory) + "\n")
fmt.Print("👉 " + productName(product.Node.Name) + " (↑" + strconv.Itoa(product.Node.VotesCount) + ") " + categoryColor(productCategory) + "\n")
fmt.Println(product.Node.Tagline)

for _, link := range product.Node.ProductLinks {
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var cfgFile string
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "/",
Short: "Producthunt CLI tool allows you to get the latest updates delivered to your CLI directly",
Long: `Enjoy your daily producthunt activity from your CLI to the updates on today's trending hunts and take actions like upvoting the products and visit the products live link without needing to use the browser.`,
Short: "Producthunt CLI application allows you to get the latest trending products delivered to your CLI directly",
Long: `Enjoy your daily producthunt activities from your CLI to get the trending product updates with the option to read the entire information about the product without need to use the browser.`,
}

func Execute() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
// viewCmd represents the view command
var viewCmd = &cobra.Command{
Use: "view",
Short: "A brief information about the product",
Long: `A detailed information related to the product of which id is passed`,
Short: "To view the prodcut information",
Long: `A detailed information related to the product and its makers.`,
Run: func(cmd *cobra.Command, args []string) {
utils.ViewProduct(args)
},
Expand Down
7 changes: 5 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func Readtoken() string {
path, _ := os.LookupEnv("HOME")
dat, err := ioutil.ReadFile(path + "/.producthunt")
if err != nil {
panic(err)
fmt.Println("Looks like you are not authenticated. Please run `producthunt-cli signin` to authenticate before performing this operation!")
defer os.Exit(0)

}
result := string(dat)
return result
Expand Down Expand Up @@ -177,7 +179,8 @@ func MakeReq(jsonData map[string]string) []byte {
response, err := client.Do(request)
s.Stop()
if err != nil {
fmt.Printf("The HTTP request failed with error %s\n", err)
fmt.Println("Looks like your token is not valid. Please run `producthunt-cli signin` to re-authenticate before performing this operation!")
defer os.Exit(0)
}
data, _ := ioutil.ReadAll(response.Body)
return data
Expand Down

0 comments on commit d6eb2ac

Please sign in to comment.