<commit_before>// Package playground is used to easily find the format of and explore the
// endpoints of the reddit api.
//
// Example useage from project root:
//
//   playground/playground --useragent=useragent.protobuf --get \
//   --url=https://oauth.reddit.com/api/v1/me
//
// This will output Reddit's JSON response to the shell.
package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"os"

	"github.com/golang/protobuf/proto"
	"github.com/paytonturnage/graw"
	"github.com/paytonturnage/graw/internal/request"
	"github.com/paytonturnage/redditproto"
)

var (
	requestURL = flag.String("url", "", "url to make a request to")
	get        = flag.Bool("get", false, "make a get request to the url")
	post       = flag.Bool("post", false, "make a post request to the url")
	userAgent  = flag.String("useragent", "", "user agent protobuf file")
)

func main() {
	flag.Parse()

	if *userAgent == "" {
		fmt.Printf("You must provide a user agent file.\n")
		os.Exit(-1)
	}

	agentBuffer, err := ioutil.ReadFile(*userAgent)
	if err != nil {
		fmt.Printf("Failed to load user agent file: %v", err)
		os.Exit(-1)
	}

	agent := &redditproto.UserAgent{}
	err = proto.Unmarshal(agentBuffer, agent)
	if err != nil {
		fmt.Printf("Failed to load user agent: %v\n", err)
		os.Exit(-1)
	}

	pilot := graw.NewUser(agent)
	if err := pilot.Auth(); err != nil {
		fmt.Printf("Failed to log user in: %v\n", err)
		os.Exit(-1)
	}

	method := ""
	if *get {
		method = "GET"
	} else if *post {
		method = "POST"
	}

	req, err := request.New(method, *requestURL, nil)
	if err != nil {
		fmt.Printf("Failed to create request: %v\n", err)
		os.Exit(-1)
	}<commit_msg>Update playground to use new User API.<commit_after>// Package playground is used to easily find the format of and explore the
// endpoints of the reddit api.
//
// Example useage from project root:
//
//   playground/playground --useragent=useragent.protobuf --get \
//   --url=https://oauth.reddit.com/api/v1/me
//
// This will output Reddit's JSON response to the shell.
package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"os"

	"github.com/paytonturnage/graw"
	"github.com/paytonturnage/graw/internal/request"
)

var (
	requestURL = flag.String("url", "", "url to make a request to")
	get        = flag.Bool("get", false, "make a get request to the url")
	post       = flag.Bool("post", false, "make a post request to the url")
	userAgent  = flag.String("useragent", "", "user agent protobuf file")
)

func main() {
	flag.Parse()

	if *userAgent == "" {
		fmt.Printf("You must provide a user agent file.\n")
		os.Exit(-1)
	}

	pilot, err := graw.NewUserFromFile(*userAgent)
	if err != nil {
		fmt.Printf("Failed to load user: %v\n", err)
	}

	if err := pilot.Auth(); err != nil {
		fmt.Printf("Failed to log user in: %v\n", err)
		os.Exit(-1)
	}

	method := ""
	if *get {
		method = "GET"
	} else if *post {
		method = "POST"
	}

	req, err := request.New(method, *requestURL, nil)
	if err != nil {
		fmt.Printf("Failed to create request: %v\n", err)
		os.Exit(-1)
	}
{'fraction_non_alphanumeric': 0.16329239960172587, 'fraction_numerical': 0.003318951211417192, 'mean_word_length': 3.2094972067039107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3931532', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1100, 'n_words': 317}