<commit_before>package cli

import (
	"fmt"
	"io"
	"os"
	"path"
	"strconv"
	"strings"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/rds"
	"github.com/honeycombio/rdslogs/publisher"
)

// Options contains all the CLI flags
type Options struct {
	Region             string `long:"region" description:"AWS region to use" default:"us-east-1"`
	InstanceIdentifier string `short:"i" long:"identifier" description:"RDS instance identifier"`
	LogFile            string `short:"f" long:"log_file" description:"RDS log file to retrieve" default:"slowquery/mysql-slowquery.log"`
	Download           bool   `short:"d" long:"download" description:"Download old logs instead of tailing the current log"`
	DownloadDir        string `long:"download_dir" description:"directory in to which log files are downloaded" default:"./"`
	NumLines           int64  `long:"num_lines" description:"number of lines to request at a time from AWS. Larger number will be more efficient, smaller number will allow for longer lines" default:"1000"`
	BackoffTimer       int64  `long:"backoff_timer" description:"how many seconds to pause when rate limited by AWS." default:"5"`
	Output             string `short:"o" long:"output" description:"output for the logs: stdout or honeycomb" default:"stdout"`
	WriteKey           string `long:"writekey" description:"Team write key, when output is honeycomb"`
	Dataset            string `long:"dataset" description:"Name of the dataset, when output is honeycomb"`
	APIHost            string `long:"api_host" description:"Hostname for the Honeycomb API server" default:"https://api.honeycomb.io/"`
	ScrubQuery         bool   `long:"scrub_query" description:"Replaces the query field with a one-way hash of the contents"`
	SampleRate         int    `long:"sample_rate" description:"Only send 1 / N log lines" default:"1"`

	Version            bool   `short:"v" long:"version" description:"Output the current version and exit"`
	ConfigFile         string `long:"config" description:"config file" no-ini:"true"`
	WriteDefaultConfig bool   `long:"write_default_config" description:"Write a default config file to STDOUT" no-ini:"true"`
	Debug              bool   `long:"debug" description:"turn on debugging output"`
}

// Usage info for --help
var Usage = `rdslogs --identifier my-rds-instance

rdslogs streams a log file from Amazon RDS and prints it to STDOUT or sends it
up to Honeycomb.io.

AWS credentials are required and can be provided via IAM roles, AWS shared<commit_msg>adding -c as short flag for config file to match other honeycomb binaries<commit_after>package cli

import (
	"fmt"
	"io"
	"os"
	"path"
	"strconv"
	"strings"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/rds"
	"github.com/honeycombio/rdslogs/publisher"
)

// Options contains all the CLI flags
type Options struct {
	Region             string `long:"region" description:"AWS region to use" default:"us-east-1"`
	InstanceIdentifier string `short:"i" long:"identifier" description:"RDS instance identifier"`
	LogFile            string `short:"f" long:"log_file" description:"RDS log file to retrieve" default:"slowquery/mysql-slowquery.log"`
	Download           bool   `short:"d" long:"download" description:"Download old logs instead of tailing the current log"`
	DownloadDir        string `long:"download_dir" description:"directory in to which log files are downloaded" default:"./"`
	NumLines           int64  `long:"num_lines" description:"number of lines to request at a time from AWS. Larger number will be more efficient, smaller number will allow for longer lines" default:"1000"`
	BackoffTimer       int64  `long:"backoff_timer" description:"how many seconds to pause when rate limited by AWS." default:"5"`
	Output             string `short:"o" long:"output" description:"output for the logs: stdout or honeycomb" default:"stdout"`
	WriteKey           string `long:"writekey" description:"Team write key, when output is honeycomb"`
	Dataset            string `long:"dataset" description:"Name of the dataset, when output is honeycomb"`
	APIHost            string `long:"api_host" description:"Hostname for the Honeycomb API server" default:"https://api.honeycomb.io/"`
	ScrubQuery         bool   `long:"scrub_query" description:"Replaces the query field with a one-way hash of the contents"`
	SampleRate         int    `long:"sample_rate" description:"Only send 1 / N log lines" default:"1"`

	Version            bool   `short:"v" long:"version" description:"Output the current version and exit"`
	ConfigFile         string `short:"c" long:"config" description:"config file" no-ini:"true"`
	WriteDefaultConfig bool   `long:"write_default_config" description:"Write a default config file to STDOUT" no-ini:"true"`
	Debug              bool   `long:"debug" description:"turn on debugging output"`
}

// Usage info for --help
var Usage = `rdslogs --identifier my-rds-instance

rdslogs streams a log file from Amazon RDS and prints it to STDOUT or sends it
up to Honeycomb.io.

AWS credentials are required and can be provided via IAM roles, AWS shared
{'fraction_non_alphanumeric': 0.10379945162553858, 'fraction_numerical': 0.004700352526439483, 'mean_word_length': 3.9727361246348587, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2786275', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1412, 'n_words': 522}