<commit_before>
package main

import (
	"os"
	"fmt"
	"github.com/jessevdk/go-flags"
)

//Options for attach
type attachOpts_t struct {

}

//Options for host
type hostOpts_t struct {

}

//Options for daemon
type daemonOpts_t struct {

}


func main() {

	//Create command options
	attachOpts := new(attachOpts_t)
	hostOpts   := new(hostOpts_t)
	daemonOpts := new(daemonOpts_t)

	//Construct parser with commands
	parser := flags.NewNamedParser("siphon", flags.HelpFlag)
	parser.AddCommand("host",   "host", "Host a process", attachOpts)
	parser.AddCommand("attach", "attach", "Attach to a host", hostOpts)
	parser.AddCommand("daemon", "daemon", "Run a daemon to spawn hosts", daemonOpts)

	//Parse arguments, handle errors/help
	args, err := parser.Parse() //whelp
	if err != nil {
		if err.(*flags.Error).Type == flags.ErrHelp { //Usage help
			fmt.Printf("%s", err)
		} else {
			fmt.Printf("Error parsing: %s\n", err)
		}
		os.Exit(1)
	}

	//Switch on command... sloppy, should integrate with go-flags
	switch os.Args[1] {

	case "attach":
		socket := ""
		if len(os.Args) < 3 {
			socket = "./siphon.sock" //default
		} else {
			socket = os.Args[2]
		}

		attach(attachOpts, socket)

	case "host":
		socket, command := "", ""
		if len(args) < 1 {
			socket = "./siphon.sock" //default
			command = "/bin/bash"
		} else if len(args) < 2 {
			socket = args[0]
			command = "/bin/bash"
		} else {
			socket = args[0]
			command = args[1]
		}

		host(attachOpts, socket, command)

	case "daemon":
		fmt.Errorf("Daemon mode is not implemented yet.")

	default:
		fmt.Errorf("Please specify attach, host, or daemon.")

	}
}<commit_msg>print only the message of errors, unless debug env var is specified in which case dump stacks.<commit_after>
package main

import (
	"os"
	"fmt"
	"github.com/jessevdk/go-flags"
)

//Options for attach
type attachOpts_t struct {

}

//Options for host
type hostOpts_t struct {

}

//Options for daemon
type daemonOpts_t struct {

}


func main() {
	defer panicHandler()

	//Create command options
	attachOpts := new(attachOpts_t)
	hostOpts   := new(hostOpts_t)
	daemonOpts := new(daemonOpts_t)

	//Construct parser with commands
	parser := flags.NewNamedParser("siphon", flags.HelpFlag)
	parser.AddCommand("host",   "host", "Host a process", attachOpts)
	parser.AddCommand("attach", "attach", "Attach to a host", hostOpts)
	parser.AddCommand("daemon", "daemon", "Run a daemon to spawn hosts", daemonOpts)

	//Parse arguments, handle errors/help
	args, err := parser.Parse() //whelp
	if err != nil {
		if err.(*flags.Error).Type == flags.ErrHelp { //Usage help
			fmt.Printf("%s", err)
		} else {
			fmt.Printf("Error parsing: %s\n", err)
		}
		os.Exit(1)
	}

	//Switch on command... sloppy, should integrate with go-flags
	switch os.Args[1] {

	case "attach":
		socket := ""
		if len(os.Args) < 3 {
			socket = "./siphon.sock" //default
		} else {
			socket = os.Args[2]
		}

		attach(attachOpts, socket)

	case "host":
		socket, command := "", ""
		if len(args) < 1 {
			socket = "./siphon.sock" //default
			command = "/bin/bash"
		} else if len(args) < 2 {
			socket = args[0]
			command = "/bin/bash"
		} else {
			socket = args[0]
			command = args[1]
		}

		host(attachOpts, socket, command)

	case "daemon":
		fmt.Errorf("Daemon mode is not implemented yet.")

	default:
		fmt.Errorf("Please specify attach, host, or daemon.")

	}
}

func panicHandler() {
	// print only the error message (don't dump stacks).
	// unless any debug mode is on; then don't recover, because we want to dump stacks.
	if len(os.Getenv("DEBUG")) == 0 {
		if err := recover(); err != nil {
			fmt.Fprintf(os.Stderr, "%s\n", err)
			os.Exit(2)
		}
	}
}
{'fraction_non_alphanumeric': 0.1540348964013086, 'fraction_numerical': 0.0054525627044711015, 'mean_word_length': 3.3012895662368114, 'pattern_counts': {'":': 6, '<': 9, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6660250', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1324, 'n_words': 367}