<commit_before>package command

import (
	"github.com/codegangsta/cli"
	"log"

	. "github.com/foostan/fileconsul/fileconsul"
)

var StatusFlags = []cli.Flag{
	cli.StringFlag{
		Name:  "addr",
		Value: "localhost:8500",
		Usage: "consul HTTP API address with port",
	},
	cli.StringFlag{
		Name:  "dc",
		Value: "dc1",
		Usage: "consul datacenter, uses local if blank",
	},
	cli.StringFlag{
		Name:  "prefix",
		Value: "fileconsul",
		Usage: "reading file status from Consul's K/V store with the given prefix",
	},
	cli.StringFlag{
		Name:  "basepath",
		Value: ".",
		Usage: "base directory path of target files",
	},
}

func StatusCommand(c *cli.Context) {
	addr := c.String("addr")
	dc := c.String("dc")
	prefix := c.String("prefix")
	basepath := c.String("basepath")

	client, err := NewClient(&ClientConfig{
		ConsulAddr: addr,
		ConsulDC:   dc,
	})
	if err != nil {
		log.Fatal(err)
	}

	lfList, err := ReadLFList(basepath)
	if err != nil {
		log.Fatal(err)
	}

	rfList, err := client.ReadRFList(prefix)
	if err != nil {
		log.Fatal(err)
	}

	rfDiff := rfList.Diff(lfList.ToRFList())

	for _, remotefile := range rfDiff.Eq {
		println("remote/local:\t" + remotefile.Path)
	}

	for _, remotefile := range rfDiff.Add {
		println("remote:\t" + remotefile.Path)
	}

	for _, remotefile := range rfDiff.Del {
		println("local:\t" + remotefile.Path)
	}

	for _, remotefile := range rfDiff.New {
		println("remote/local:(modified)\t" + remotefile.Path)
	}
}<commit_msg>Show status message like git<commit_after>package command

import (
	"github.com/codegangsta/cli"
	"log"
	"fmt"
	"path/filepath"

	. "github.com/foostan/fileconsul/fileconsul"
)

var StatusFlags = []cli.Flag{
	cli.StringFlag{
		Name:  "addr",
		Value: "localhost:8500",
		Usage: "consul HTTP API address with port",
	},
	cli.StringFlag{
		Name:  "dc",
		Value: "dc1",
		Usage: "consul datacenter, uses local if blank",
	},
	cli.StringFlag{
		Name:  "prefix",
		Value: "fileconsul",
		Usage: "reading file status from Consul's K/V store with the given prefix",
	},
	cli.StringFlag{
		Name:  "basepath",
		Value: ".",
		Usage: "base directory path of target files",
	},
}

func StatusCommand(c *cli.Context) {
	addr := c.String("addr")
	dc := c.String("dc")
	prefix := c.String("prefix")
	basepath := c.String("basepath")

	client, err := NewClient(&ClientConfig{
		ConsulAddr: addr,
		ConsulDC:   dc,
	})
	if err != nil {
		log.Fatal(err)
	}

	lfList, err := ReadLFList(basepath)
	if err != nil {
		log.Fatal(err)
	}

	rfList, err := client.ReadRFList(prefix)
	if err != nil {
		log.Fatal(err)
	}

	lfrfList := lfList.ToRFList()
	rfDiff := lfrfList.Diff(rfList)

	if !lfrfList.Equal(rfList) {
		fmt.Println("Changes to be pushed:\n  (use \"fileconsul pull [command options]\" to reset all files)")
	}

	for _, remotefile := range rfDiff.Add {
		println("\tnew file:\t" + filepath.Join(basepath, remotefile.Path))
	}

	for _, remotefile := range rfDiff.Del {
		println("\tdeleted:\t" + filepath.Join(basepath, remotefile.Path))
	}

	for _, remotefile := range rfDiff.New {
		println("\tmodified:\t" + filepath.Join(basepath, remotefile.Path))
	}
}
{'fraction_non_alphanumeric': 0.16237942122186494, 'fraction_numerical': 0.003215434083601286, 'mean_word_length': 3.838258164852255, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5905787', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1194, 'n_words': 267}