Skip to content

Commit 370aee0

Browse files
committed
clean up command verbs a bit
1 parent 1230531 commit 370aee0

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

cmd/dupenron/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func indexEnron(index *dupi.Indexer, fname string) error {
120120
doc := &dupi.Doc{
121121
Path: fname, //"/" + rcd[0],
122122
Dat: msg,
123-
Start: uint32(offset)}
123+
Start: offset + uint32(ibody) + 2 + uint32(len(rcd[0]))}
124124
doc.End = offset + uint32(len(doc.Dat))
125125
offset = doc.End
126126
index.Add(doc)

cmd/dupi/dupi.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import (
2929
// TBD: write and use newIndex(), newExtract()
3030
// instead of init() ugliness
3131
var scMap = map[string]SubCmd{
32-
"index": index,
33-
"extract": extract,
32+
"index": newIndexCmd(),
33+
"extract": newExtractCmd(),
3434
"blot": newBlotCmd(),
3535
"unblot": newUnblotCmd()}
3636

@@ -69,15 +69,16 @@ func splitArgs(args []string) ([]string, []string) {
6969
}
7070

7171
func usage(w io.Writer) {
72-
fmt.Fprintf(w, "usage: dupi [global opts] <cmd> <args>\n")
73-
fmt.Fprintf(w, "commands are:\n")
72+
fmt.Fprintf(w, "usage: dupi [global opts] <verb> <args>\n")
73+
fmt.Fprintf(w, "verbs are:\n")
7474
for k, v := range scMap {
7575
fmt.Fprintf(w, "\t%-10s %30s\n", k, v.Usage())
7676
}
7777
fmt.Fprintf(w, "\nglobal options:\n")
7878
gFlags.VisitAll(func(f *flag.Flag) {
7979
fmt.Fprintf(w, "\t-%-16s default=%-16q %s\n", f.Name, f.DefValue, f.Usage)
8080
})
81+
fmt.Fprintf(w, "\nTo get help on a verb, try dupi <verb> -h.\n")
8182
}
8283

8384
func usageFatal(w io.Writer) {

cmd/dupi/extract.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ type extractCmd struct {
3030
json *bool
3131
}
3232

33-
var extract = &extractCmd{subCmd: subCmd{
34-
name: "extract",
35-
usage: "extract [args]",
36-
flags: flag.NewFlagSet("extract", flag.ExitOnError)}}
33+
func newExtractCmd() *extractCmd {
34+
var extract = &extractCmd{subCmd: subCmd{
35+
name: "extract",
36+
usage: "extract [args]",
37+
flags: flag.NewFlagSet("extract", flag.ExitOnError)}}
3738

38-
func init() {
3939
extract.json = extract.flags.Bool("json", false, "output json")
40+
return extract
4041
}
4142

4243
func (x *extractCmd) Usage() string {

cmd/dupi/index.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,18 @@ type indexCmd struct {
3636
indexer *dupi.Indexer
3737
}
3838

39-
var index = &indexCmd{
40-
subCmd: subCmd{
41-
name: "index",
42-
flags: flag.NewFlagSet("index", flag.ExitOnError)}}
43-
44-
func init() {
45-
index.shards = index.flags.Int("n", 4, "shards")
39+
func newIndexCmd() *indexCmd {
40+
var index = &indexCmd{
41+
subCmd: subCmd{
42+
name: "index",
43+
flags: flag.NewFlagSet("index", flag.ExitOnError)}}
4644
index.seqlen = index.flags.Int("t", 10, "similarity based seq len")
4745
index.add = index.flags.Bool("a", false, "add to a given existing index")
4846
index.verbose = index.flags.Bool("v", false, "verbose")
4947
index.nshat = index.flags.Int("s", 4, "num shatterers")
48+
return index
5049
}
5150

52-
var _ SubCmd = index
53-
5451
func (x *indexCmd) Usage() string {
5552
return "paths"
5653
}

shatter.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ func (s *shatter) send(did uint32) {
137137

138138
func (s *shatter) blot(docid, b uint32) {
139139
n := uint32(len(s.d))
140-
141140
i := b % n
142141
s.d[i] = append(s.d[i], post.Make(docid, b/n))
143142
}

0 commit comments

Comments
 (0)