Renaming.
This commit is contained in:
parent
4a8ba3f6e2
commit
aca5d0bd05
4 changed files with 43 additions and 42 deletions
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module github.com/omnipunk/tk
|
module github.com/omnipunk/bb
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
|
|
54
main.go
54
main.go
|
@ -4,32 +4,32 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/omnipunk/cli/mtool"
|
||||||
|
|
||||||
"github.com/omnipunk/tk/tool/cat"
|
"github.com/omnipunk/bb/tool/cat"
|
||||||
"github.com/omnipunk/tk/tool/date"
|
"github.com/omnipunk/bb/tool/date"
|
||||||
"github.com/omnipunk/tk/tool/ec"
|
"github.com/omnipunk/bb/tool/ec"
|
||||||
"github.com/omnipunk/tk/tool/echo"
|
"github.com/omnipunk/bb/tool/echo"
|
||||||
"github.com/omnipunk/tk/tool/ftest"
|
"github.com/omnipunk/bb/tool/ftest"
|
||||||
"github.com/omnipunk/tk/tool/grange"
|
"github.com/omnipunk/bb/tool/grange"
|
||||||
"github.com/omnipunk/tk/tool/in"
|
"github.com/omnipunk/bb/tool/in"
|
||||||
"github.com/omnipunk/tk/tool/ln"
|
"github.com/omnipunk/bb/tool/ln"
|
||||||
"github.com/omnipunk/tk/tool/ls"
|
"github.com/omnipunk/bb/tool/ls"
|
||||||
"github.com/omnipunk/tk/tool/mergelbl"
|
"github.com/omnipunk/bb/tool/mergelbl"
|
||||||
"github.com/omnipunk/tk/tool/mkdir"
|
"github.com/omnipunk/bb/tool/mkdir"
|
||||||
"github.com/omnipunk/tk/tool/paths"
|
"github.com/omnipunk/bb/tool/paths"
|
||||||
"github.com/omnipunk/tk/tool/quote"
|
"github.com/omnipunk/bb/tool/quote"
|
||||||
"github.com/omnipunk/tk/tool/read"
|
"github.com/omnipunk/bb/tool/read"
|
||||||
"github.com/omnipunk/tk/tool/sort"
|
"github.com/omnipunk/bb/tool/sort"
|
||||||
"github.com/omnipunk/tk/tool/tac"
|
"github.com/omnipunk/bb/tool/tac"
|
||||||
"github.com/omnipunk/tk/tool/uniq"
|
"github.com/omnipunk/bb/tool/uniq"
|
||||||
"github.com/omnipunk/tk/tool/urlprs"
|
"github.com/omnipunk/bb/tool/urlprs"
|
||||||
"github.com/omnipunk/tk/tool/useprog"
|
"github.com/omnipunk/bb/tool/useprog"
|
||||||
"github.com/omnipunk/tk/tool/wc"
|
"github.com/omnipunk/bb/tool/wc"
|
||||||
"github.com/omnipunk/tk/tool/whoami"
|
"github.com/omnipunk/bb/tool/whoami"
|
||||||
"github.com/omnipunk/tk/tool/yes"
|
"github.com/omnipunk/bb/tool/yes"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var root = mtool.T("tk").Subs(
|
var root = mtool.T("bb").Subs(
|
||||||
mtool.T("cat").Func(cat.Run).Desc(
|
mtool.T("cat").Func(cat.Run).Desc(
|
||||||
"concatenate files",
|
"concatenate files",
|
||||||
).Usage(
|
).Usage(
|
||||||
|
@ -45,10 +45,10 @@ var root = mtool.T("tk").Subs(
|
||||||
).Usage(
|
).Usage(
|
||||||
"[str1 str2 ...strN]",
|
"[str1 str2 ...strN]",
|
||||||
),
|
),
|
||||||
mtool.T("true").Func(func(flags *mtool.Flags){
|
mtool.T("true").Func(func(flags *mtool.Flags) {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}).Desc("exit successfuly"),
|
}).Desc("exit successfuly"),
|
||||||
mtool.T("false").Func(func(flags *mtool.Flags){
|
mtool.T("false").Func(func(flags *mtool.Flags) {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}).Desc("exit with failure"),
|
}).Desc("exit with failure"),
|
||||||
mtool.T("sort").Func(sort.Run).Desc(
|
mtool.T("sort").Func(sort.Run).Desc(
|
||||||
|
@ -110,7 +110,7 @@ var root = mtool.T("tk").Subs(
|
||||||
mtool.T("paths").Func(paths.Run).Desc(
|
mtool.T("paths").Func(paths.Run).Desc(
|
||||||
"print different parts of paths",
|
"print different parts of paths",
|
||||||
),
|
),
|
||||||
mtool.T("env").Func(func(flags *mtool.Flags){
|
mtool.T("env").Func(func(flags *mtool.Flags) {
|
||||||
flags.Parse()
|
flags.Parse()
|
||||||
envs := os.Environ()
|
envs := os.Environ()
|
||||||
for _, env := range envs {
|
for _, env := range envs {
|
||||||
|
@ -120,7 +120,7 @@ var root = mtool.T("tk").Subs(
|
||||||
"print all the environment variables",
|
"print all the environment variables",
|
||||||
),
|
),
|
||||||
).Desc(
|
).Desc(
|
||||||
"ToolKit, BusyBox-like not POSIX-compatible utilities",
|
"not POSIX compatible BusyBox utilities",
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"github.com/omnipunk/tk/input"
|
"github.com/omnipunk/bb/input"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/omnipunk/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,35 @@
|
||||||
/* Yes program implementation. */
|
/* Yes program implementation. */
|
||||||
package yes
|
package yes
|
||||||
|
|
||||||
import(
|
import (
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"github.com/omnipunk/tk/input"
|
"github.com/omnipunk/bb/input"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/omnipunk/cli/mtool"
|
||||||
)
|
)
|
||||||
var(
|
|
||||||
|
var (
|
||||||
nArg int
|
nArg int
|
||||||
)
|
)
|
||||||
|
|
||||||
func yes(s string){
|
func yes(s string) {
|
||||||
if nArg<0{
|
if nArg < 0 {
|
||||||
for{
|
for {
|
||||||
fmt.Print(s)
|
fmt.Print(s)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i:=0 ; i<nArg ; i+=1 {
|
for i := 0; i < nArg; i += 1 {
|
||||||
fmt.Print(s)
|
fmt.Print(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run(flagSet *mtool.Flags) {
|
func Run(flagSet *mtool.Flags) {
|
||||||
var(
|
var (
|
||||||
stdinFlag bool
|
stdinFlag bool
|
||||||
nFlag bool
|
nFlag bool
|
||||||
s string
|
s string
|
||||||
)
|
)
|
||||||
flagSet.BoolVar(&stdinFlag, "s", false, "Read string from stdin.")
|
flagSet.BoolVar(&stdinFlag, "s", false, "Read string from stdin.")
|
||||||
flagSet.BoolVar(&nFlag, "n", false, "Do not add net line character.")
|
flagSet.BoolVar(&nFlag, "n", false, "Do not add net line character.")
|
||||||
|
@ -41,7 +42,7 @@ func Run(flagSet *mtool.Flags) {
|
||||||
in, _ := input.ReadAllRaw(os.Stdin)
|
in, _ := input.ReadAllRaw(os.Stdin)
|
||||||
s = string(in)
|
s = string(in)
|
||||||
} else {
|
} else {
|
||||||
if len(args)>0 {
|
if len(args) > 0 {
|
||||||
s = strings.Join(args, " ")
|
s = strings.Join(args, " ")
|
||||||
} else {
|
} else {
|
||||||
s = "y"
|
s = "y"
|
||||||
|
|
Loading…
Reference in a new issue