<commit_before>package cmd

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"os/exec"
	"strconv"
	"strings"

	"github.com/fatih/color"
	"github.com/spf13/cobra"
)

var pagenation int
var argument string

type Qiita struct {
	Title string `json: "title"`
	Url   string `json: "url"`
}

var searchCmd = &cobra.Command{
	Use:   "search",
	Short: "Call Api of Qiita",
	Long:  "Call Api of Qiita",
	Run: func(cmd *cobra.Command, args []string) {
		pagenation = 1
		argument = strings.Join(args, ",")
		resp, err := http.Get("http://qiita.com/api/v2/items?page=" + strconv.Itoa(pagenation) + "&per_page=10&query=" + argument)
		if err == nil {
			puts(resp)
		} else {
			fmt.Println(err)
		}
	},
}

func init() {
	RootCmd.AddCommand(searchCmd)
}

func puts(resp *http.Response) {
	defer resp.Body.Close()
	b, err := ioutil.ReadAll(resp.Body)
	if err == nil {
		var content interface{}
		json.Unmarshal(b, &content)
		for i := 0; i < 10; i++ {
			fmt.Print(color.YellowString(strconv.Itoa(i) + " -> "))
			fmt.Println(content.([]interface{})[i].(map[string]interface{})["title"].(string))
		}
		var num string
		fmt.Println(color.YellowString("n -> ") + "next page")
		fmt.Print("SELECT > ")
		_, errr := fmt.Scanf("%s", &num)
		number, _ := strconv.Atoi(num)
		if errr == nil {
			errrr := exec.Command("open", content.([]interface{})[number].(map[string]interface{})["url"].(string)).Run()
			if errrr != nil {
				fmt.Println(errrr)
			}
		}
	} else {
		fmt.Println(err)
	}
}<commit_msg>Add next page search<commit_after>package cmd

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"os/exec"
	"strconv"
	"strings"

	"github.com/fatih/color"
	"github.com/spf13/cobra"
)

var pagenation int
var argument string

type Qiita struct {
	Title string `json: "title"`
	Url   string `json: "url"`
}

var searchCmd = &cobra.Command{
	Use:   "search",
	Short: "Call Api of Qiita",
	Long:  "Call Api of Qiita",
	Run: func(cmd *cobra.Command, args []string) {
		pagenation = 1
		argument = strings.Join(args, ",")
		execute()
	},
}

func init() {
	RootCmd.AddCommand(searchCmd)
}

func execute() {
	resp, err := http.Get("http://qiita.com/api/v2/items?page=" + strconv.Itoa(pagenation) + "&per_page=10&query=" + argument)
	if err == nil {
		defer resp.Body.Close()
		b, errr := ioutil.ReadAll(resp.Body)
		if errr == nil {
			rendering(b)
		}
	}
}

func rendering(b []byte) {
	var content interface{}
	json.Unmarshal(b, &content)
	for i := 0; i < 10; i++ {
		fmt.Print(color.YellowString(strconv.Itoa(i) + " -> "))
		fmt.Println(content.([]interface{})[i].(map[string]interface{})["title"].(string))
	}
	fmt.Println(color.YellowString("n -> ") + "next page")
	fmt.Print("SELECT > ")
	scan(content)
}

func scan(content interface{}) {
	var num string
	_, err := fmt.Scanf("%s", &num)
	if err == nil {
		if num == "n" {
			pagenation++
			execute()
		} else {
			numb, _ := strconv.Atoi(num)
			exec.Command("open", content.([]interface{})[numb].(map[string]interface{})["url"].(string)).Run()
		}
	} else {
		fmt.Println(err)
	}
}
{'fraction_non_alphanumeric': 0.19637561779242174, 'fraction_numerical': 0.005930807248764415, 'mean_word_length': 3.8190476190476192, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1011357', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1230, 'n_words': 241}