<commit_before>package command

import (
	"fmt"
	"strconv"
	"strings"
)

// TokenRenewCommand is a Command that mounts a new mount.
type TokenRenewCommand struct {
	Meta
}

func (c *TokenRenewCommand) Run(args []string) int {
	var format string
	flags := c.Meta.FlagSet("token-renew", FlagSetDefault)
	flags.StringVar(&format, "format", "table", "")
	flags.Usage = func() { c.Ui.Error(c.Help()) }
	if err := flags.Parse(args); err != nil {
		return 1
	}

	args = flags.Args()
	if len(args) < 1 {
		flags.Usage()
		c.Ui.Error(fmt.Sprintf(
			"\ntoken-renew expects at least one argument"))
		return 1
	}

	var increment int
	token := args[0]
	if len(args) > 1 {
		value, err := strconv.ParseInt(args[1], 10, 0)
		if err != nil {
			c.Ui.Error(fmt.Sprintf("Invalid increment: %s", err))
			return 1
		}

		increment = int(value)
	}

	client, err := c.Client()
	if err != nil {
		c.Ui.Error(fmt.Sprintf(
			"Error initializing client: %s", err))
		return 2
	}

	secret, err := client.Auth().Token().Renew(token, increment)
	if err != nil {<commit_msg>Use RenewSelf instead of Renew if the token we're renewing is the same as the client<commit_after>package command

import (
	"fmt"
	"strconv"
	"strings"

	"github.com/hashicorp/vault/api"
)

// TokenRenewCommand is a Command that mounts a new mount.
type TokenRenewCommand struct {
	Meta
}

func (c *TokenRenewCommand) Run(args []string) int {
	var format string
	flags := c.Meta.FlagSet("token-renew", FlagSetDefault)
	flags.StringVar(&format, "format", "table", "")
	flags.Usage = func() { c.Ui.Error(c.Help()) }
	if err := flags.Parse(args); err != nil {
		return 1
	}

	args = flags.Args()
	if len(args) < 1 {
		flags.Usage()
		c.Ui.Error(fmt.Sprintf(
			"\ntoken-renew expects at least one argument"))
		return 1
	}

	var increment int
	token := args[0]
	if len(args) > 1 {
		value, err := strconv.ParseInt(args[1], 10, 0)
		if err != nil {
			c.Ui.Error(fmt.Sprintf("Invalid increment: %s", err))
			return 1
		}

		increment = int(value)
	}

	client, err := c.Client()
	if err != nil {
		c.Ui.Error(fmt.Sprintf(
			"Error initializing client: %s", err))
		return 2
	}

	// If the given token is the same as the client's, use renew-self instead
	// as this is far more likely to be allowed via policy
	var secret *api.Secret
	if client.Token() == token {
		secret, err = client.Auth().Token().RenewSelf(increment)
	} else {
		secret, err = client.Auth().Token().Renew(token, increment)
	}
	if err != nil {
{'fraction_non_alphanumeric': 0.1516876779178528, 'fraction_numerical': 0.008946726311508743, 'mean_word_length': 3.5220588235294117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6849578', 'n_tokens_mistral': 964, 'n_tokens_neox': 877, 'n_words': 258}