dirs for each subcmd
This commit is contained in:
parent
a05ebf985a
commit
8bd0da003e
6 changed files with 53 additions and 3 deletions
2
go.mod
2
go.mod
|
|
@ -1,3 +1,3 @@
|
||||||
module github.com/brtholomy/um
|
module github.com/brtholomy/um/go
|
||||||
|
|
||||||
go 1.25.4
|
go 1.25.4
|
||||||
|
|
|
||||||
14
next/last.go
Normal file
14
next/last.go
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
package next
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Last() {
|
||||||
|
ls, err := exec.Command("ls").Output()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Print(err)
|
||||||
|
}
|
||||||
|
fmt.Printf("ls\n%s\n", string(ls))
|
||||||
|
}
|
||||||
8
next/next.go
Normal file
8
next/next.go
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
package next
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func Next(args []string) {
|
||||||
|
fmt.Println("next")
|
||||||
|
fmt.Println(args)
|
||||||
|
}
|
||||||
10
sort/sort.go
Normal file
10
sort/sort.go
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
package sort
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Sort(args []string) {
|
||||||
|
fmt.Println("sort")
|
||||||
|
fmt.Println(args)
|
||||||
|
}
|
||||||
10
tag/tag.go
Normal file
10
tag/tag.go
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
package tag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Tag(args []string) {
|
||||||
|
fmt.Println("tag")
|
||||||
|
fmt.Println(args)
|
||||||
|
}
|
||||||
12
um.go
12
um.go
|
|
@ -5,6 +5,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
nextpkg "github.com/brtholomy/um/go/next"
|
||||||
|
sortpkg "github.com/brtholomy/um/go/sort"
|
||||||
|
tagpkg "github.com/brtholomy/um/go/tag"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Subcommand string
|
type Subcommand string
|
||||||
|
|
@ -62,16 +66,20 @@ func main() {
|
||||||
|
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case next:
|
case next:
|
||||||
fmt.Printf("args: %#v\n", args)
|
nextpkg.Next(args)
|
||||||
|
case last:
|
||||||
|
nextpkg.Last()
|
||||||
case tag:
|
case tag:
|
||||||
|
// TODO: move flag defs to the package?
|
||||||
tagFlags.Parse(prependFlagToArgs(args, query))
|
tagFlags.Parse(prependFlagToArgs(args, query))
|
||||||
fmt.Println(tag)
|
tagpkg.Tag(args)
|
||||||
fmt.Printf("query: %#v\n", *tagQuery)
|
fmt.Printf("query: %#v\n", *tagQuery)
|
||||||
fmt.Printf("invert: %#v\n", *tagInvert)
|
fmt.Printf("invert: %#v\n", *tagInvert)
|
||||||
fmt.Printf("args: %#v\n", tagFlags.Args())
|
fmt.Printf("args: %#v\n", tagFlags.Args())
|
||||||
tagFlags.Usage()
|
tagFlags.Usage()
|
||||||
case sort:
|
case sort:
|
||||||
sortFlags.Parse(args)
|
sortFlags.Parse(args)
|
||||||
|
sortpkg.Sort(args)
|
||||||
fmt.Println("subcmd sort")
|
fmt.Println("subcmd sort")
|
||||||
fmt.Printf("key: %#v\n", *sortKey)
|
fmt.Printf("key: %#v\n", *sortKey)
|
||||||
fmt.Printf("args: %#v\n", sortFlags.Args())
|
fmt.Printf("args: %#v\n", sortFlags.Args())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue