flags : more common help functions, but redefining the subcmds in each package is probably wrong, esp. since last had to be deduped
This commit is contained in:
parent
0ff9e6d9a3
commit
77e3e23446
5 changed files with 31 additions and 14 deletions
14
next/next.go
14
next/next.go
|
|
@ -10,6 +10,8 @@ import (
|
|||
"github.com/brtholomy/um/go/flags"
|
||||
)
|
||||
|
||||
const cmd = "next"
|
||||
|
||||
type options struct {
|
||||
Descriptor flags.Arg
|
||||
Tags flags.Arg
|
||||
|
|
@ -33,10 +35,10 @@ func parseArgs(args []string) options {
|
|||
case i == 1 && !flags.HasDashPrefix(arg):
|
||||
opts.Tags.Val = arg
|
||||
case arg == opts.Help.Long || arg == opts.Help.Short:
|
||||
flags.Help("next", opts)
|
||||
flags.Help(cmd, opts)
|
||||
default:
|
||||
log.Printf("um next: invalid argument: %s", arg)
|
||||
flags.Help("next", opts)
|
||||
flags.HelpInvalidArg(cmd, arg)
|
||||
flags.Help(cmd, opts)
|
||||
}
|
||||
}
|
||||
return opts
|
||||
|
|
@ -107,13 +109,13 @@ func Next(args []string) {
|
|||
opts := parseArgs(args)
|
||||
l, err := last()
|
||||
if err != nil {
|
||||
log.Fatalf("um next: %v", err)
|
||||
log.Fatalf("um %s: %v", cmd, err)
|
||||
}
|
||||
filename, err := next(l, opts.Descriptor.Val)
|
||||
if err != nil {
|
||||
log.Fatalf("um next: %v", err)
|
||||
log.Fatalf("um %s: %v", cmd, err)
|
||||
}
|
||||
if err := emacsNext(filename, opts.Tags.Val); err != nil {
|
||||
log.Fatalf("um next: %v", err)
|
||||
log.Fatalf("um %s: %v", cmd, err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue