<commit_before>package main

import(
  "fmt"
  "os"
  "os/exec"
  "github.com/jessevdk/go-flags"
  "github.com/kr/s3/s3util"
  "path/filepath"
  "io/ioutil"
  "runtime"
)

const VERSION = "0.1.0"

var options struct {
  Prefix   string `long:"prefix"    description:"Archive prefix"`
  Path     string `long:"path"      description:"Path to cache"`
  Manifest string `long:"manifest"  description:"Path to Gemfile.lock or package.json"`
  S3Key    string `long:"s3-key"    description:"Amazon S3 access key"`
  S3Secret string `long:"s3-secret" description:"Amazon S3 secret key"`
  S3Bucket string `long:"s3-bucket" description:"Amazon S3 bucket name"`
}

func printUsage() {
  fmt.Printf("Bunch v%s\n", VERSION)
  fmt.Println("Usage: bunch [upload|download]")
}

func loadS3Credentials() {
  if envDefined("S3_KEY") {
    options.S3Key = os.Getenv("S3_KEY")
  }

  if envDefined("S3_SECRET") {
    options.S3Secret = os.Getenv("S3_SECRET")
  }

  if envDefined("S3_BUCKET") {
    options.S3Bucket = os.Getenv("S3_BUCKET")
  }
}

func setS3Credentials() {
  s3util.DefaultConfig.AccessKey = options.S3Key
  s3util.DefaultConfig.SecretKey = options.S3Secret
}

func checkOptions() {
  if len(options.Prefix) == 0   { fatal("Please specify --prefix")    }
  if len(options.Manifest) == 0 { fatal("Please specify --manifest")  }
  if len(options.Path) == 0     { fatal("Please specify --path")      }
  if len(options.S3Key) == 0    { fatal("Please specify --s3-key")    }
  if len(options.S3Secret) == 0 { fatal("Please specify --s3-secret") }
  if len(options.S3Bucket) == 0 { fatal("Please specify --s3-bucket") }
}

// Expand path arguments to support tildas. Example: "~/path" 
//
func expandPathArguments() {
  options.Path = expandPath(options.Path)
  options.Manifest = expandPath(options.Manifest)
}

// Extract an archive to a path. Returs true on success
//
// extract("/tmp/archive.tar.gz", "/path/to/extract")
//
func extract(filename string, path string) bool {
  // Create a directory to extract archive to
  if _, err := exec.Command("mkdir", path).Output() ; err != nil {
    fmt.Println("Unable to create extaction path")
    return false
  }

  // Extract tarball to created directory
  if _, err := exec.Command("tar", "-xzf", filename, "-C", path).Output() ; err != nil {
    fmt.Println("Unable to extract archive")
    return false
  }

  return true
}
<commit_msg>Compare options to strings instead of checking on len<commit_after>package main

import(
  "fmt"
  "os"
  "os/exec"
  "github.com/jessevdk/go-flags"
  "github.com/kr/s3/s3util"
  "path/filepath"
  "io/ioutil"
  "runtime"
)

const VERSION = "0.1.0"

var options struct {
  Prefix   string `long:"prefix"    description:"Archive prefix"`
  Path     string `long:"path"      description:"Path to cache"`
  Manifest string `long:"manifest"  description:"Path to Gemfile.lock or package.json"`
  S3Key    string `long:"s3-key"    description:"Amazon S3 access key"`
  S3Secret string `long:"s3-secret" description:"Amazon S3 secret key"`
  S3Bucket string `long:"s3-bucket" description:"Amazon S3 bucket name"`
}

func printUsage() {
  fmt.Printf("Bunch v%s\n", VERSION)
  fmt.Println("Usage: bunch [upload|download]")
}

func loadS3Credentials() {
  if envDefined("S3_KEY") {
    options.S3Key = os.Getenv("S3_KEY")
  }

  if envDefined("S3_SECRET") {
    options.S3Secret = os.Getenv("S3_SECRET")
  }

  if envDefined("S3_BUCKET") {
    options.S3Bucket = os.Getenv("S3_BUCKET")
  }
}

func setS3Credentials() {
  s3util.DefaultConfig.AccessKey = options.S3Key
  s3util.DefaultConfig.SecretKey = options.S3Secret
}

func checkOptions() {
  if options.Prefix == ""   { fatal("Please specify --prefix")    }
  if options.Manifest == "" { fatal("Please specify --manifest")  }
  if options.Path == ""     { fatal("Please specify --path")      }
  if options.S3Key == ""    { fatal("Please specify --s3-key")    }
  if options.S3Secret == "" { fatal("Please specify --s3-secret") }
  if options.S3Bucket == "" { fatal("Please specify --s3-bucket") }
}

// Expand path arguments to support tildas. Example: "~/path" 
//
func expandPathArguments() {
  options.Path = expandPath(options.Path)
  options.Manifest = expandPath(options.Manifest)
}

// Extract an archive to a path. Returs true on success
//
// extract("/tmp/archive.tar.gz", "/path/to/extract")
//
func extract(filename string, path string) bool {
  // Create a directory to extract archive to
  if _, err := exec.Command("mkdir", path).Output() ; err != nil {
    fmt.Println("Unable to create extaction path")
    return false
  }

  // Extract tarball to created directory
  if _, err := exec.Command("tar", "-xzf", filename, "-C", path).Output() ; err != nil {
    fmt.Println("Unable to extract archive")
    return false
  }

  return true
}

{'fraction_non_alphanumeric': 0.15121136173767752, 'fraction_numerical': 0.015873015873015872, 'mean_word_length': 3.582775119617225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6280230', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1640, 'n_words': 396}