diff --git a/go.mod b/go.mod index 038140e..6268f7d 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index bed06d2..27a74bb 100644 --- a/go.sum +++ b/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= diff --git a/main.go b/main.go index 7e6bce1..5eb2776 100644 --- a/main.go +++ b/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" ) diff --git a/readme.md b/readme.md index a680a6e..dc5b449 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/tool/cat/cat.go b/tool/cat/cat.go index 177d235..720721b 100644 --- a/tool/cat/cat.go +++ b/tool/cat/cat.go @@ -4,7 +4,7 @@ import( "os" "io" "fmt" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) var( diff --git a/tool/date/date.go b/tool/date/date.go index c56f2ae..499350d 100644 --- a/tool/date/date.go +++ b/tool/date/date.go @@ -3,7 +3,7 @@ package date import( "fmt" "time" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func Run(flagSet *mtool.Flags) { diff --git a/tool/ec/run.go b/tool/ec/run.go index 5edb4e8..44d665d 100644 --- a/tool/ec/run.go +++ b/tool/ec/run.go @@ -6,7 +6,7 @@ import( "os" "bufio" "log" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) const( diff --git a/tool/echo/echo.go b/tool/echo/echo.go index c20d75d..cb5c172 100644 --- a/tool/echo/echo.go +++ b/tool/echo/echo.go @@ -3,7 +3,7 @@ package echo import ( "fmt" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) var( diff --git a/tool/finfo/main.go b/tool/finfo/main.go new file mode 100644 index 0000000..c5b30bc --- /dev/null +++ b/tool/finfo/main.go @@ -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) + } + } +} diff --git a/tool/ftest/main.go b/tool/ftest/main.go index ac53985..5d301d5 100644 --- a/tool/ftest/main.go +++ b/tool/ftest/main.go @@ -5,7 +5,7 @@ import ( "io" "bufio" "fmt" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" "path/filepath" ) diff --git a/tool/gfalse/false.go b/tool/gfalse/false.go index 22bf173..762fbb0 100644 --- a/tool/gfalse/false.go +++ b/tool/gfalse/false.go @@ -2,7 +2,7 @@ package gfalse import( "os" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func Run(flags *mtool.Flags) { diff --git a/tool/grange/main.go b/tool/grange/main.go index 41c71cf..664bfea 100644 --- a/tool/grange/main.go +++ b/tool/grange/main.go @@ -3,7 +3,7 @@ package grange import( "fmt" "strconv" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) var( diff --git a/tool/gtrue/true.go b/tool/gtrue/true.go index 6c45ace..147bc32 100644 --- a/tool/gtrue/true.go +++ b/tool/gtrue/true.go @@ -1,5 +1,5 @@ package gtrue -import "github.com/omnipunk/cli/mtool" +import "github.com/di4f/cli/mtool" func Run(flags *mtool.Flags) {} diff --git a/tool/in/main.go b/tool/in/main.go index b904e6f..04712cb 100644 --- a/tool/in/main.go +++ b/tool/in/main.go @@ -5,7 +5,7 @@ import ( "io" "bufio" "fmt" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func Run(flagSet *mtool.Flags) { diff --git a/tool/ln/main.go b/tool/ln/main.go index ae4ecf9..f9b2434 100644 --- a/tool/ln/main.go +++ b/tool/ln/main.go @@ -3,7 +3,7 @@ package ln import ( "fmt" "os" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" "path/filepath" ) diff --git a/tool/ls/ls.go b/tool/ls/ls.go index 7ff27c2..b8f2753 100644 --- a/tool/ls/ls.go +++ b/tool/ls/ls.go @@ -5,7 +5,7 @@ import( "strings" "regexp" "path" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) var( diff --git a/tool/mergelbl/main.go b/tool/mergelbl/main.go index a2812d3..6121037 100644 --- a/tool/mergelbl/main.go +++ b/tool/mergelbl/main.go @@ -5,7 +5,7 @@ import( "fmt" "bufio" "log" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func Run(flagSet *mtool.Flags) { diff --git a/tool/mkdir/mkdir.go b/tool/mkdir/mkdir.go index ad66c50..48bff9a 100644 --- a/tool/mkdir/mkdir.go +++ b/tool/mkdir/mkdir.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func Run(flagSet *mtool.Flags) { diff --git a/tool/noext/noext.go b/tool/noext/noext.go index 61c5fdd..7e1c950 100644 --- a/tool/noext/noext.go +++ b/tool/noext/noext.go @@ -3,7 +3,7 @@ package noext import( "fmt" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) var( diff --git a/tool/paths/main.go b/tool/paths/main.go index 8101a03..9647835 100644 --- a/tool/paths/main.go +++ b/tool/paths/main.go @@ -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 ( diff --git a/tool/quote/quote.go b/tool/quote/quote.go index 657909e..6b3e8cf 100644 --- a/tool/quote/quote.go +++ b/tool/quote/quote.go @@ -7,7 +7,7 @@ import( "fmt" "unicode" "bufio" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func HasWhiteSpace(s string) bool { diff --git a/tool/read/main.go b/tool/read/main.go index cf70bd3..579874b 100644 --- a/tool/read/main.go +++ b/tool/read/main.go @@ -4,7 +4,7 @@ import( "os" "bufio" "fmt" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) var( diff --git a/tool/sort/sort.go b/tool/sort/sort.go index c97eee1..eaa9644 100644 --- a/tool/sort/sort.go +++ b/tool/sort/sort.go @@ -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) { diff --git a/tool/tac/tac.go b/tool/tac/tac.go index f5c4a1c..a11c8ed 100644 --- a/tool/tac/tac.go +++ b/tool/tac/tac.go @@ -5,7 +5,7 @@ import( "io" "fmt" "bufio" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func reverse(a []string) chan string { diff --git a/tool/uniq/uniq.go b/tool/uniq/uniq.go index 5485434..f8bc4f0 100644 --- a/tool/uniq/uniq.go +++ b/tool/uniq/uniq.go @@ -6,7 +6,7 @@ import( "fmt" "bufio" "io" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func Run(flagSet *mtool.Flags) { diff --git a/tool/urlprs/urlprs.go b/tool/urlprs/urlprs.go index 9e5850a..2d71f5f 100644 --- a/tool/urlprs/urlprs.go +++ b/tool/urlprs/urlprs.go @@ -5,7 +5,7 @@ import ( "fmt" "net" "net/url" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) var nilStr = "_" diff --git a/tool/useprog/main.go b/tool/useprog/main.go index 3b5b4d4..48b1334 100644 --- a/tool/useprog/main.go +++ b/tool/useprog/main.go @@ -4,7 +4,7 @@ import ( "os" "os/exec" "fmt" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" "path/filepath" ) diff --git a/tool/wc/main.go b/tool/wc/main.go index 8f7c716..4eb7d30 100644 --- a/tool/wc/main.go +++ b/tool/wc/main.go @@ -7,7 +7,7 @@ import ( "fmt" "unicode" "strconv" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) var ( diff --git a/tool/whoami/main.go b/tool/whoami/main.go index 0330176..d38fa74 100644 --- a/tool/whoami/main.go +++ b/tool/whoami/main.go @@ -5,7 +5,7 @@ import( "os/user" "fmt" "log" - "github.com/omnipunk/cli/mtool" + "github.com/di4f/cli/mtool" ) func Run(flagSet *mtool.Flags) { diff --git a/tool/yes/yes.go b/tool/yes/yes.go index 33c54c1..28ea1bf 100644 --- a/tool/yes/yes.go +++ b/tool/yes/yes.go @@ -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 (