<commit_before>package main

import (
	//"byte"
	//"crypto/x509"
	"bufio"
	"fmt"
	"os"
	"regexp"
)

func main() {
	//TODO: read commands
	//catapult user@server:port --keyfile  --password --passphrase

	//split strings with escape of \ for spaces in arguments
	r := regexp.MustCompile("(\\\\.|[^\\s])+")
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		input := scanner.Text()
		//TODO: read gets and puts commands here
		args := r.FindAllString(input, -1)
		switch cmd := args[0]; cmd {
		case "gets":<commit_msg>parsing args<commit_after>package main

import (
	//"byte"
	//"crypto/x509"
	"bufio"
	"flag"
	"fmt"
	"os"
	"regexp"
	"strings"
	"golang.org/x/crypto/ssh"
)

//catapult [-keyfile=... [-passphrase=..] | -password=.. ] user@server:port

var client *ssh.Client
var password string
var passphrase string
var keyfile string

func usage() {
	fmt.Fprintf(os.Stderr,"catapult <flags> user@server:port\n")
	fmt.Fprintln(os.Stderr,"")
	fmt.Fprintln(os.Stderr,"Note: flags must come before connection string")
}

func init() {
	flag.StringVar(&password, "password", "", "password for sftp connection")
	flag.StringVar(&passphrase, "passphrase", "", "passphrase for keyfile")
	flag.StringVar(&keyfile, "keyfile", "", "keyfile path")
}

func main() {
	flag.Parse()

	if (flag.NArg() != 1) {
		usage()
		os.Exit(2)
	}

	connection := strings.SplitN(flag.Arg(0), "@", 2)
	if (len(connection) != 2) {
		usage()
		os.Exit(2)
	}
	username := connection[0]
	address := connection[1]

	config := &ssh.ClientConfig{
		User: username,
	}

	if keyfile != "" {
		config.Auth = []ssh.AuthMethod{ ssh.Password(password) }
	} else if password != "" {
		config.Auth = []ssh.AuthMethod{ ssh.Password(password) }
	} else {
		fmt.Fprintln(os.Stderr, "Need password or keyfile")
	}

	hasPort, err := regexp.MatchString(".+:\\d+", address)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(2)
	}
	if !hasPort {
		address = address + ":22"
	}

	fmt.Println(username, address)

	client, err = ssh.Dial("tcp", address, config)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Failed to connect to server")
		fmt.Fprintln(os.Stderr, err)
		os.Exit(2)
	}

	//split strings with escape of \ for spaces in arguments
	r := regexp.MustCompile("(\\\\.|[^\\s])+")
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		input := scanner.Text()
		//TODO: read gets and puts commands here
		args := r.FindAllString(input, -1)
		switch cmd := args[0]; cmd {
		case "gets":
{'fraction_non_alphanumeric': 0.1844029244516653, 'fraction_numerical': 0.008935824532900082, 'mean_word_length': 3.718390804597701, 'pattern_counts': {'":': 3, '<': 4, '<?xml version=': 0, '>': 4, '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': '4346894', 'n_tokens_mistral': 990, 'n_tokens_neox': 929, 'n_words': 219}