...
This commit is contained in:
parent
aca5d0bd05
commit
8169d4a8c0
30 changed files with 142 additions and 58 deletions
4
go.mod
4
go.mod
|
@ -1,5 +1,5 @@
|
|||
module github.com/omnipunk/bb
|
||||
module github.com/di4f/bb
|
||||
|
||||
go 1.18
|
||||
|
||||
require github.com/omnipunk/cli v0.0.0-20231111174053-707875fd6a00
|
||||
require github.com/di4f/cli v0.0.0-20231214183522-32f786133a58
|
||||
|
|
6
go.sum
6
go.sum
|
@ -1,4 +1,2 @@
|
|||
github.com/omnipunk/cli v0.0.0-20231110091353-f877427ca833 h1:sNNDuH0hbT+3Mqh200JM54ZAQPt0g9LsOeUzMMadg+4=
|
||||
github.com/omnipunk/cli v0.0.0-20231110091353-f877427ca833/go.mod h1:j1oX8nchf3eIbEvGLIDe+glTXT/Mkz6w4UO1/3EQ8tc=
|
||||
github.com/omnipunk/cli v0.0.0-20231111174053-707875fd6a00 h1:/yDyAzahNPrj3lzksfO6wfqk2pC8R1djXhbLjD2evOw=
|
||||
github.com/omnipunk/cli v0.0.0-20231111174053-707875fd6a00/go.mod h1:j1oX8nchf3eIbEvGLIDe+glTXT/Mkz6w4UO1/3EQ8tc=
|
||||
github.com/di4f/cli v0.0.0-20231214183522-32f786133a58 h1:b3bk2zD7YqLJDYoNAGawVbJovkNzJPDULYuF6+ar09w=
|
||||
github.com/di4f/cli v0.0.0-20231214183522-32f786133a58/go.mod h1:a2hUcQVjIEYR0VW3gf640cgbxCvUwA9vwKvkSkw1SUU=
|
||||
|
|
46
main.go
46
main.go
|
@ -2,30 +2,30 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
|
||||
"github.com/omnipunk/bb/tool/cat"
|
||||
"github.com/omnipunk/bb/tool/date"
|
||||
"github.com/omnipunk/bb/tool/ec"
|
||||
"github.com/omnipunk/bb/tool/echo"
|
||||
"github.com/omnipunk/bb/tool/ftest"
|
||||
"github.com/omnipunk/bb/tool/grange"
|
||||
"github.com/omnipunk/bb/tool/in"
|
||||
"github.com/omnipunk/bb/tool/ln"
|
||||
"github.com/omnipunk/bb/tool/ls"
|
||||
"github.com/omnipunk/bb/tool/mergelbl"
|
||||
"github.com/omnipunk/bb/tool/mkdir"
|
||||
"github.com/omnipunk/bb/tool/paths"
|
||||
"github.com/omnipunk/bb/tool/quote"
|
||||
"github.com/omnipunk/bb/tool/read"
|
||||
"github.com/omnipunk/bb/tool/sort"
|
||||
"github.com/omnipunk/bb/tool/tac"
|
||||
"github.com/omnipunk/bb/tool/uniq"
|
||||
"github.com/omnipunk/bb/tool/urlprs"
|
||||
"github.com/omnipunk/bb/tool/useprog"
|
||||
"github.com/omnipunk/bb/tool/wc"
|
||||
"github.com/omnipunk/bb/tool/whoami"
|
||||
"github.com/omnipunk/bb/tool/yes"
|
||||
"github.com/di4f/bb/tool/cat"
|
||||
"github.com/di4f/bb/tool/date"
|
||||
"github.com/di4f/bb/tool/ec"
|
||||
"github.com/di4f/bb/tool/echo"
|
||||
"github.com/di4f/bb/tool/ftest"
|
||||
"github.com/di4f/bb/tool/grange"
|
||||
"github.com/di4f/bb/tool/in"
|
||||
"github.com/di4f/bb/tool/ln"
|
||||
"github.com/di4f/bb/tool/ls"
|
||||
"github.com/di4f/bb/tool/mergelbl"
|
||||
"github.com/di4f/bb/tool/mkdir"
|
||||
"github.com/di4f/bb/tool/paths"
|
||||
"github.com/di4f/bb/tool/quote"
|
||||
"github.com/di4f/bb/tool/read"
|
||||
"github.com/di4f/bb/tool/sort"
|
||||
"github.com/di4f/bb/tool/tac"
|
||||
"github.com/di4f/bb/tool/uniq"
|
||||
"github.com/di4f/bb/tool/urlprs"
|
||||
"github.com/di4f/bb/tool/useprog"
|
||||
"github.com/di4f/bb/tool/wc"
|
||||
"github.com/di4f/bb/tool/whoami"
|
||||
"github.com/di4f/bb/tool/yes"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# tk
|
||||
|
||||
![Insert here a gopher, please](https://raw.githubusercontent.com/omnipunk/tk//master/media/gopher.png)
|
||||
![Insert here a gopher, please](https://raw.githubusercontent.com/di4f/tk//master/media/gopher.png)
|
||||
|
||||
Gopher ToolKit. Not POSIX compatible BusyBox-like set of programs
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import(
|
|||
"os"
|
||||
"io"
|
||||
"fmt"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var(
|
||||
|
|
|
@ -3,7 +3,7 @@ package date
|
|||
import(
|
||||
"fmt"
|
||||
"time"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func Run(flagSet *mtool.Flags) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import(
|
|||
"os"
|
||||
"bufio"
|
||||
"log"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
const(
|
||||
|
|
|
@ -3,7 +3,7 @@ package echo
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var(
|
||||
|
|
86
tool/finfo/main.go
Normal file
86
tool/finfo/main.go
Normal file
|
@ -0,0 +1,86 @@
|
|||
package finfo
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/di4f/cli/mtool"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var (
|
||||
flags [lastFlag] bool
|
||||
flagVals []Flag
|
||||
)
|
||||
|
||||
type Flag uint8
|
||||
|
||||
const (
|
||||
SizeFlag Flag = 1 << iota
|
||||
ModeFlag
|
||||
ModTimeFlag
|
||||
LastFlag
|
||||
)
|
||||
|
||||
func checkFile(p string) bool {
|
||||
p = filepath.FromSlash(p)
|
||||
for _, v := range flagList {
|
||||
if !flagMap[v](p){
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Fileinfo(flags []Flag, p string) string {
|
||||
p = filepath.FromSlash(p)
|
||||
ret := p
|
||||
for _, flag := range flags {
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
func Run(flagSet *mtool.Flags) {
|
||||
flagSet.BoolVar(
|
||||
&flags[sizeFlag],
|
||||
false,
|
||||
"print size of files",
|
||||
)
|
||||
|
||||
flagSet.BoolVar(
|
||||
&flags[modeFlag],
|
||||
false,
|
||||
"print mode of files",
|
||||
)
|
||||
flagSet.BoolVar(
|
||||
&flags[modTimeFlag],
|
||||
false,
|
||||
"print last modification time in standard Golang format",
|
||||
)
|
||||
flagSet.Parse()
|
||||
args := flagSet.Args()
|
||||
|
||||
for _, p := range args {
|
||||
checkFile(p)
|
||||
}
|
||||
|
||||
rd := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
s, err := rd.ReadString('\n')
|
||||
if err == io.EOF {
|
||||
os.Exit(0)
|
||||
} else if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if s[len(s)-1] == '\n' {
|
||||
s = s[:len(s)-1]
|
||||
}
|
||||
|
||||
if checkFile(s) {
|
||||
fmt.Println(s)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import (
|
|||
"io"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package gfalse
|
|||
|
||||
import(
|
||||
"os"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func Run(flags *mtool.Flags) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package grange
|
|||
import(
|
||||
"fmt"
|
||||
"strconv"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package gtrue
|
||||
|
||||
import "github.com/omnipunk/cli/mtool"
|
||||
import "github.com/di4f/cli/mtool"
|
||||
|
||||
func Run(flags *mtool.Flags) {}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"io"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func Run(flagSet *mtool.Flags) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package ln
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import(
|
|||
"strings"
|
||||
"regexp"
|
||||
"path"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var(
|
||||
|
|
|
@ -5,7 +5,7 @@ import(
|
|||
"fmt"
|
||||
"bufio"
|
||||
"log"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func Run(flagSet *mtool.Flags) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
|
||||
"path/filepath"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func Run(flagSet *mtool.Flags) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package noext
|
|||
|
||||
import(
|
||||
"fmt"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var(
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"path"
|
||||
"strings"
|
||||
|
||||
//"github.com/omnipunk/tk/pathx"
|
||||
//"github.com/di4f/tk/pathx"
|
||||
"path/filepath"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -7,7 +7,7 @@ import(
|
|||
"fmt"
|
||||
"unicode"
|
||||
"bufio"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func HasWhiteSpace(s string) bool {
|
||||
|
|
|
@ -4,7 +4,7 @@ import(
|
|||
"os"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var(
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"github.com/omnipunk/bb/input"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/bb/input"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func Run(flagSet *mtool.Flags) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import(
|
|||
"io"
|
||||
"fmt"
|
||||
"bufio"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func reverse(a []string) chan string {
|
||||
|
|
|
@ -6,7 +6,7 @@ import(
|
|||
"fmt"
|
||||
"bufio"
|
||||
"io"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func Run(flagSet *mtool.Flags) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var nilStr = "_"
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"fmt"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"fmt"
|
||||
"unicode"
|
||||
"strconv"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -5,7 +5,7 @@ import(
|
|||
"os/user"
|
||||
"fmt"
|
||||
"log"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
func Run(flagSet *mtool.Flags) {
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"os"
|
||||
"fmt"
|
||||
"strings"
|
||||
"github.com/omnipunk/bb/input"
|
||||
"github.com/omnipunk/cli/mtool"
|
||||
"github.com/di4f/bb/input"
|
||||
"github.com/di4f/cli/mtool"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
Loading…
Reference in a new issue