<commit_before>//Copyright 2014 <NAME>. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file

//Package kademliadht is the kademliaservice
package kademliadht

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"

	"github.com/AaronGoldman/ccfs/objects"
	"github.com/AaronGoldman/ccfs/services"
)

//Instance is the instance of the kademliaservice
var Instance kademliaservice
var running bool

func init() {
	services.Registercommand(
		Instance,
		"kademliadht command", //This is the usage string
	)
	services.Registerrunner(Instance)
}

//Start registers kademliadhtservice instances
func Start() {
	Instance = kademliaservicefactory()
	services.Registerblobgeter(Instance)
	services.Registercommitgeter(Instance)
	services.Registertaggeter(Instance)
	//services.Registertagsgeter(Instance)
	services.Registerkeygeter(Instance)
	services.Registerblobposter(Instance)
	services.Registercommitposter(Instance)
	services.Registertagposter(Instance)
	services.Registerkeyposter(Instance)
	running = true

}

//Stop deregisters kademliadhtservice instances
func Stop() {
	services.DeRegisterblobgeter(Instance)
	services.DeRegistercommitgeter(Instance)
	services.DeRegistertaggeter(Instance)
	//services.DeRegistertagsgeter(Instance)
	services.DeRegisterkeygeter(Instance)
	services.DeRegisterblobposter(Instance)
	services.DeRegistercommitposter(Instance)
	services.DeRegistertagposter(Instance)
	services.DeRegisterkeyposter(Instance)
	running = false
}

type kademliaservice struct {
	url string
}

//Running returns a bool that indicates the registration status of the service
func (k kademliaservice) Running() bool {
	return running
}

//ID gets the ID string
func (k kademliaservice) ID() string {
	return "kademliadht"
}

func (k kademliaservice) Command(command string) {
	switch command {
	case "start":
		Start()

	case "stop":
		Stop()

	default:
		fmt.Printf("Kademlia Service Command Line\n")
		return
	}

}
<commit_msg>Added a set command to Kademliadht so one can set the url from the command line<commit_after>//Copyright 2014 <NAME>. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file

//Package kademliadht is the kademliaservice
package kademliadht

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"strings"
	"unicode"

	"github.com/AaronGoldman/ccfs/objects"
	"github.com/AaronGoldman/ccfs/services"
)

//Instance is the instance of the kademliaservice
var Instance kademliaservice
var running bool

func init() {
	services.Registercommand(
		Instance,
		"kademliadht command", //This is the usage string
	)
	services.Registerrunner(Instance)
}

//Start registers kademliadhtservice instances
func Start() {
	Instance = kademliaservicefactory()
	services.Registerblobgeter(Instance)
	services.Registercommitgeter(Instance)
	services.Registertaggeter(Instance)
	//services.Registertagsgeter(Instance)
	services.Registerkeygeter(Instance)
	services.Registerblobposter(Instance)
	services.Registercommitposter(Instance)
	services.Registertagposter(Instance)
	services.Registerkeyposter(Instance)
	running = true

}

//Stop deregisters kademliadhtservice instances
func Stop() {
	services.DeRegisterblobgeter(Instance)
	services.DeRegistercommitgeter(Instance)
	services.DeRegistertaggeter(Instance)
	//services.DeRegistertagsgeter(Instance)
	services.DeRegisterkeygeter(Instance)
	services.DeRegisterblobposter(Instance)
	services.DeRegistercommitposter(Instance)
	services.DeRegistertagposter(Instance)
	services.DeRegisterkeyposter(Instance)
	running = false
}

type kademliaservice struct {
	url string
}

//Running returns a bool that indicates the registration status of the service
func (k kademliaservice) Running() bool {
	return running
}

//ID gets the ID string
func (k kademliaservice) ID() string {
	return "kademliadht"
}

func (k kademliaservice) Command(command string) {
	tokens := strings.FieldsFunc(command, unicode.IsSpace)
	if len(tokens) == 0 {
		return
	}
	switch tokens[0] {
	case "start":
		Start()

	case "stop":
		Stop()

	case "set":
		if len(tokens) > 1 {
			k.url = fmt.Sprintf("http://%s/?\n", tokens[1])
			fmt.Printf("URL set to: %s", k.url)
		}

	default:
		fmt.Printf("Kademlia Service Command Line\n")
		return
	}

}

{'fraction_non_alphanumeric': 0.09474412171507607, 'fraction_numerical': 0.0027662517289073307, 'mean_word_length': 5.390279823269514, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 6, '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': '4997799', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1407, 'n_words': 351}