• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 11 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Some CLI utilities written in Go. Mainly intended as Unixlike commands for Windows, but cross-platform anyway. Just because

someutils

Some CLI utilities written in Go.

  • Mainly intended as Unix-like commands for Windows, but cross-platform anyway.

  • Covers similar ground to coreutils, but not intended as a replacement. (Won't ever support all commands & options).

  • Just because.

  • WARNING: someutils isn't intended for use as a library YET. The API can and will change, with the idea being to facilitate cross-platform, shell-like scripting in Go.

  • New and Experimental in v0.5: you can use someutils as a library (but the API will change)

    pipeline := someutils.NewPipeline(someutils.Wrap(wget.WgetToOut()), Head(2), Tr("h", "G")) invocation, out, errout := pipeline.InvokeReader(strings.NewReader("www.golang.org\n")) lastOrErrInvocation := invocation.Wait() fmt.Println(out.String())

Installation.

Method 1: download precompiled binaries (recommended for when you're not currently running go):

  • Grab some recent (v0.3.0) Windows binaries zipped up for 32-bit Windows and 64-bit Windows.
  • Just unzip somewhere on your %PATH% (environment variable).
  • (These binaries were built and uploaded with goxc, ofcourse)

Method 2: go get all binaries into your GOPATH

NOTE: On Unix systems in particular, be careful that your system PATH elements come BEFORE GOPATH within your PATH environment variable

  1. go get github.com/laher/someutils/./...
  2. ls, pwd etc

You could also use go get to pick out a subset of those commands.

Method 3: just install the some command, (similar to busybox):

  1. go get github.com/laher/someutils/cmd/some
  2. some ls, some pwd etc
  3. Optionally, use alias or doskey to make some behave more like busybox.

Scope etc

My initial target is to get my Windows CLI a bit closer to being as productive as my Linux CLI, by creating many small utilities under one umbrella. Then, who knows. I do like the idea of a Go/Linux, as opposed to Gnu/Linux :)

Some commands are not included, because they're either ubiquitous anyway (such as echo,cd,whoami), just too big, or hard to acheive with pure Go.

I'll just keep adding stuff as I need it. Contributions welcome!

Progress

So far, limited versions of the following commands are available: You can also use 'some [cmd] [args...]' for any of these.

Command Options supported STDIN support Notes
basename TODO: -a, -z
cat -Ens Yes
cp -r n/a TODO: check symlink behaviour. Test large file support
dirname n/a
grep -nvHi -E -P Yes TODO: binary files support. !!No support for BRE - uses -E by default.
gunzip -k TODO TODO: -f, prompt when file exists
gzip -k TODO TODO: -f, prompt when file exists
head -n Yes TODO: -c
ls -lahr -1 Yes TODO: -p -t
mv n/a TODO: check symlink behaviour
pwd n/a
rm -r n/a TODO: check symlink behaviour
scp -r -P ? INCOMPLETE - see scp-go .
sleep n/a
tail -n -F Yes TODO: -c, -f (by descriptor rather than by name). Bug: won't currently print last line unless terminated by a CR.
tar -cvf -x -t -r Yes (IN+OUT) Just the core functionality so far.
tr Yes
tee -a Yes TODO: -i
touch n/a
unzip -t TODO(STDOUT) Password support would not be straightforward (not supported by standard lib)
wc -c -l -w
which -a n/a
wget -c -o n/a TODO: multi-threading? (not part of real wget). See wget-go
zip TODO Password support would not be straightforward (not supported by standard lib)

ToMaybeDo

  • stat,size,file,type
  • split,join,sort
  • shred
  • chmod/chown (relevant? Yes I think so)
  • diff (too big? Maybe a minimal version would be good here)
  • more (how easy is it?)
  • du/dh (need OS-specifics: syscall would probably cover it for Unix and Windows)
  • find/locate (find is a bit of a monster. locate is probably a stretch)
  • ln (would it need some non-Go stuff for Windows? Yes - maybe an 'exec' at this stage)
  • ps,kill,pgrep,pkill (need to explore mileage of os.FindProcess, syscall.Kill)
  • id,w (is it doable cross-platform?)
  • sshd (minimal version, for hosting file transfers etc), ssh (maybe just for running remote commands. Terminal handling might be too challenging for now)
  • traceroute (see wtn. Requires setuid & therefore chowning + chmodding on Unix - on Windows I think you'd just need to run as administrator)
  • ping (see above)
  • dig (I think. Raw DNS requests & collect responses. Hmm, investigate go.net packages)
  • chroot (chroot possible for unix via syscall - see gobox)

TooBig?

  • less
  • a text editor
  • top
  • dd (I guess. Maybe not)
  • awk, sed
  • xargs, find -exec
  • rsync (algorithms might be a bit hard)
  • cron (I guess service handling is another chapter aswell)

Not possible/easy with pure Go

  • bg,fg
  • fsck

See Also

  • I have separated out the 'flag' functionality, and some other relevant behaviour, into a separate package, uggo
  • I drew inspiration early on from a couple of similar projects - many thanks to gobox and go-coreutils. In both cases I considered a fork but my focus is just a little too different to make it feasible. Cheers guys

More Repositories

1

goxc

a build tool for Go, with a focus on cross-compiling, packaging and deployment
Go
1,677
star
2

fuzzymenu.vim

menu system for vim/neovim, using fzf for fuzzy selection
Vim Script
56
star
3

wget-go

wget, partially re-implemented in go
Go
41
star
4

neorg-exec

code block execution for neorg (similar to org-eval)
Lua
35
star
5

ChordialJS

Chord chart utility for web. Make progressions and interactive tabluation apps
JavaScript
27
star
6

mergefs

go package to chain fs.FS filesystems together (go1.16+)
Go
24
star
7

scp-go

scp clone for go. Initially just password-based auth, then adding 'keys'. Would also be good to add known_hosts support
Go
23
star
8

gopin

experimental go-get fork with support for tags and alternative repos
Go
16
star
9

gols

list go packages, ignoring specific folders (especially '/vendor/')
Go
10
star
10

marshalfs

Simulate a readonly filesystem in Go, by defining objects/functions and a marshalling function
Go
9
star
11

dotfiles

Dotfiles (managed with stow)
Lua
8
star
12

swugger

This is a temporary repo intended to start a discussion about swagger support for httprouter (and others), based on go-restful/swagger
Go
8
star
13

bump

Bump a given semver version (major/minor/patch)
Go
7
star
14

uggo

Ungraceful Gnu-ification for Go
Go
6
star
15

debgo-v0.2

functionality for building debs in Go. Covers similar ground to dpkg,dpkg-deb and dpkg-source
Go
6
star
16

voteo

video voting app (toy)
Go
5
star
17

toasties-galore

Resources for a talk about Continuous Deployment for Gophercon AU
Go
5
star
18

yt

YAML processor in the spirit of jq/sed
HTML
5
star
19

vendoff

Disable/enable a Go vendor folder, with this shell script
Shell
5
star
20

gothx.vim

A go plugin for vim/nvim, which only tries to do things that gopls doesn't do. thx.
Vim Script
5
star
21

regopher

refactoring tools for go [experimental]
Go
4
star
22

regopher.vim

vim plugin for regopher [experimental]
Vim Script
3
star
23

go16-maps

Code for a talk about using maps in Go1.6
Go
3
star
24

smoosh

Smoosh is an experimental shell language written in Go
Go
3
star
25

kc

wrappers for some kubectl commands
Go
3
star
26

argo

Support for .ar archives in Go
Go
3
star
27

sshutils-go

ssh utilities for go
Go
3
star
28

fooball

An experimental football (soccer) game engine for HTML canvas. Early doors.
JavaScript
2
star
29

debgo-v0

dpkg-like functionality for building debs in Go
Go
2
star
30

nilcheck

Check for nils inside arbitrary data structures (Go)
Go
1
star
31

fooball-server

Experimental authoritative-server for a browser-based sports game. Uses websockets
Scala
1
star
32

grammy

experimental markup-based diagramming wizboing
Go
1
star
33

passr

Password manager - experimental
Go
1
star
34

git-wary

Wary merging - for more predictable releases
Shell
1
star
35

clicache

Cache the STDOUT of a given command, for up to n minutes
Go
1
star
36

servicetray

customisable system tray widget for a group of related services
Go
1
star
37

gophertron

Use case for a short talk on coverage testing & httptest
Go
1
star
38

concrete

generating concrete structs from interfaces (Go)
Go
1
star
39

promsortrules

Sort and reformat prometheus alerts file alphabetically
Go
1
star
40

kdisco

kidsco: a kubernetes service which simply lists pods with a given label
Go
1
star
41

neorg-codecap

a capture popup for neorg. Captures info about the file you're in (gitlink or file/line)
Lua
1
star
42

context-example

Example usage of the context package, for a lightning talk at GoAKL
Go
1
star
43

wtn

What The Net - connectivity problem analyser
Go
1
star
44

oklogrus

experimental work for logrus forwarding to oklog
1
star