Skip to content

Swiss army knife for manipulating strings.

License

Notifications You must be signed in to change notification settings

Allaman/gstring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gstring

GoReleaser Logo

Release size issues last commit license last release

Swiss army knife for working with strings

gstring

Use cases

❯ gstring --help
Usage: gstring <command> [flags]

A tool to work with strings

Flags:
  -h, --help    Show context-sensitive help.
  -t, --trim    Trim output (for piping)

Commands:
  base64 encode        Encodes with base64
  base64 decode        Decodes with base64
  count bytes          Counts bytes
  count chars          Counts characters
  count words          Counts words
  case camel           formatsCamelCase
  case lower           formats lower
  case random          ForMats rANdom CaSE
  case snake           formats_snake_case
  case upper           FORMATS UPPER
  hash sha256          Calculates Sha256
  hash sha512          Calculates Sha512
  hash md5             Calculates MD5
  head                 Returns the first n lines
  hex to               Converts to hexadecimal
  hex from             Converts hexadecimal back
  lorem bytes          Returns Bytes
  lorem paragraphs     Returns Paragraphs
  lorem sentences      Returns Sentences
  lorem words          Returns Words
  htpasswd             Create a htpasswd string
  permissions          Parses Unix permissions
  pwgen                Password generator (letters and numbers)
  remove-whitespace    Removes whitespace
  reverse              Reverses the input
  rng                  Random number generator
  sort                 Sorts the input by line
  split                Splits a string
  tail                 Returns the last n lines
  time from-unix       Converts from Unix time to normal time
  time get-unix        Returns Unix time
  url encode           Encodes string to valid URL
  url decode           Decodes URL to string
  version              Shows version information

Run "gstring <command> --help" for more information on a command.

Get gstring

with curl

VERSION=$(curl -s https://api.github.com/repos/allaman/gstring/releases/latest | grep tag_name | cut -d '"' -f 4)
curl -sLo gstring https://github.com/Allaman/gstring/releases/download/${VERSION}/gstring_${VERSION}_$(uname -s)_$(uname -m)

with wget

VERSION=$(wget -qO - https://api.github.com/repos/allaman/gstring/releases/latest | grep tag_name | cut -d '"' -f 4)
wget -qO gstring https://github.com/Allaman/gstring/releases/download/${VERSION}/gstring_${VERSION}_$(uname -s)_$(uname -m)
chmod +x gstring
./gstring

Usage

Most of the commands work with stdin so you have to pipe content, for example:

echo "hello world" | gstring case camel
gstring hash sha256 < main.go # equivalent to sha256sum main.go
date +%s | gstring time from-unix -f "2006-01-02 15:04"

However, some commands read from named arguments, for example:

gstring htpasswd -u bar -p test
gstring lorem sentences -c 20
gstring rng -s 1 -e 100 -c 10 -d ";"
gstring pwgen -n 20 -c 10 -d ";"
gstring permissions -p 3755

What about the name?

Well, of course, from Golang and string. What are you thinking?