...
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
|
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/di4f/cli v0.0.0-20231214183522-32f786133a58 h1:b3bk2zD7YqLJDYoNAGawVbJovkNzJPDULYuF6+ar09w=
|
||||||
github.com/omnipunk/cli v0.0.0-20231110091353-f877427ca833/go.mod h1:j1oX8nchf3eIbEvGLIDe+glTXT/Mkz6w4UO1/3EQ8tc=
|
github.com/di4f/cli v0.0.0-20231214183522-32f786133a58/go.mod h1:a2hUcQVjIEYR0VW3gf640cgbxCvUwA9vwKvkSkw1SUU=
|
||||||
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=
|
|
||||||
|
|
46
main.go
46
main.go
|
@ -2,30 +2,30 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
|
|
||||||
"github.com/omnipunk/bb/tool/cat"
|
"github.com/di4f/bb/tool/cat"
|
||||||
"github.com/omnipunk/bb/tool/date"
|
"github.com/di4f/bb/tool/date"
|
||||||
"github.com/omnipunk/bb/tool/ec"
|
"github.com/di4f/bb/tool/ec"
|
||||||
"github.com/omnipunk/bb/tool/echo"
|
"github.com/di4f/bb/tool/echo"
|
||||||
"github.com/omnipunk/bb/tool/ftest"
|
"github.com/di4f/bb/tool/ftest"
|
||||||
"github.com/omnipunk/bb/tool/grange"
|
"github.com/di4f/bb/tool/grange"
|
||||||
"github.com/omnipunk/bb/tool/in"
|
"github.com/di4f/bb/tool/in"
|
||||||
"github.com/omnipunk/bb/tool/ln"
|
"github.com/di4f/bb/tool/ln"
|
||||||
"github.com/omnipunk/bb/tool/ls"
|
"github.com/di4f/bb/tool/ls"
|
||||||
"github.com/omnipunk/bb/tool/mergelbl"
|
"github.com/di4f/bb/tool/mergelbl"
|
||||||
"github.com/omnipunk/bb/tool/mkdir"
|
"github.com/di4f/bb/tool/mkdir"
|
||||||
"github.com/omnipunk/bb/tool/paths"
|
"github.com/di4f/bb/tool/paths"
|
||||||
"github.com/omnipunk/bb/tool/quote"
|
"github.com/di4f/bb/tool/quote"
|
||||||
"github.com/omnipunk/bb/tool/read"
|
"github.com/di4f/bb/tool/read"
|
||||||
"github.com/omnipunk/bb/tool/sort"
|
"github.com/di4f/bb/tool/sort"
|
||||||
"github.com/omnipunk/bb/tool/tac"
|
"github.com/di4f/bb/tool/tac"
|
||||||
"github.com/omnipunk/bb/tool/uniq"
|
"github.com/di4f/bb/tool/uniq"
|
||||||
"github.com/omnipunk/bb/tool/urlprs"
|
"github.com/di4f/bb/tool/urlprs"
|
||||||
"github.com/omnipunk/bb/tool/useprog"
|
"github.com/di4f/bb/tool/useprog"
|
||||||
"github.com/omnipunk/bb/tool/wc"
|
"github.com/di4f/bb/tool/wc"
|
||||||
"github.com/omnipunk/bb/tool/whoami"
|
"github.com/di4f/bb/tool/whoami"
|
||||||
"github.com/omnipunk/bb/tool/yes"
|
"github.com/di4f/bb/tool/yes"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# tk
|
# 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
|
Gopher ToolKit. Not POSIX compatible BusyBox-like set of programs
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import(
|
||||||
"os"
|
"os"
|
||||||
"io"
|
"io"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var(
|
var(
|
||||||
|
|
|
@ -3,7 +3,7 @@ package date
|
||||||
import(
|
import(
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(flagSet *mtool.Flags) {
|
func Run(flagSet *mtool.Flags) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import(
|
||||||
"os"
|
"os"
|
||||||
"bufio"
|
"bufio"
|
||||||
"log"
|
"log"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
const(
|
const(
|
||||||
|
|
|
@ -3,7 +3,7 @@ package echo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var(
|
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"
|
"io"
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package gfalse
|
||||||
|
|
||||||
import(
|
import(
|
||||||
"os"
|
"os"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(flags *mtool.Flags) {
|
func Run(flags *mtool.Flags) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package grange
|
||||||
import(
|
import(
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var(
|
var(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package gtrue
|
package gtrue
|
||||||
|
|
||||||
import "github.com/omnipunk/cli/mtool"
|
import "github.com/di4f/cli/mtool"
|
||||||
|
|
||||||
func Run(flags *mtool.Flags) {}
|
func Run(flags *mtool.Flags) {}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(flagSet *mtool.Flags) {
|
func Run(flagSet *mtool.Flags) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package ln
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import(
|
||||||
"strings"
|
"strings"
|
||||||
"regexp"
|
"regexp"
|
||||||
"path"
|
"path"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var(
|
var(
|
||||||
|
|
|
@ -5,7 +5,7 @@ import(
|
||||||
"fmt"
|
"fmt"
|
||||||
"bufio"
|
"bufio"
|
||||||
"log"
|
"log"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(flagSet *mtool.Flags) {
|
func Run(flagSet *mtool.Flags) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(flagSet *mtool.Flags) {
|
func Run(flagSet *mtool.Flags) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package noext
|
||||||
|
|
||||||
import(
|
import(
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var(
|
var(
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
//"github.com/omnipunk/tk/pathx"
|
//"github.com/di4f/tk/pathx"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -7,7 +7,7 @@ import(
|
||||||
"fmt"
|
"fmt"
|
||||||
"unicode"
|
"unicode"
|
||||||
"bufio"
|
"bufio"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HasWhiteSpace(s string) bool {
|
func HasWhiteSpace(s string) bool {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import(
|
||||||
"os"
|
"os"
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var(
|
var(
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"github.com/omnipunk/bb/input"
|
"github.com/di4f/bb/input"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(flagSet *mtool.Flags) {
|
func Run(flagSet *mtool.Flags) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import(
|
||||||
"io"
|
"io"
|
||||||
"fmt"
|
"fmt"
|
||||||
"bufio"
|
"bufio"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func reverse(a []string) chan string {
|
func reverse(a []string) chan string {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import(
|
||||||
"fmt"
|
"fmt"
|
||||||
"bufio"
|
"bufio"
|
||||||
"io"
|
"io"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(flagSet *mtool.Flags) {
|
func Run(flagSet *mtool.Flags) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var nilStr = "_"
|
var nilStr = "_"
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"unicode"
|
"unicode"
|
||||||
"strconv"
|
"strconv"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -5,7 +5,7 @@ import(
|
||||||
"os/user"
|
"os/user"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(flagSet *mtool.Flags) {
|
func Run(flagSet *mtool.Flags) {
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"github.com/omnipunk/bb/input"
|
"github.com/di4f/bb/input"
|
||||||
"github.com/omnipunk/cli/mtool"
|
"github.com/di4f/cli/mtool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in a new issue